This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| int user_data; | |
| std::cin >> user_data; | |
| std::cout << "You have entered " << user_data << std::endl; | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <cmath> | |
| int main() { | |
| int x = 4.2 * std::pow(10., 9.); | |
| unsigned int y = 4.2 * std::pow(10., 9.); | |
| std::cout << x << ", " << y << std::endl; | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| int binary {0b101010}; | |
| int octal {0734}; | |
| unsigned int hexadecimal {0xDEADBEEF}; | |
| int decimal {1234}; | |
| std::cout << binary << std::endl | |
| << octal << std::endl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| //pomijam binarny zapis, ze względu na brak manipulatora dla niego | |
| int octal {0734}; | |
| unsigned int hexadecimal {0xDEADBEEF}; | |
| int decimal {1234}; | |
| std::cout << std::oct << octal << std::endl | |
| << std::hex << hexadecimal << std::endl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <utility> //std::move | |
| struct B { | |
| int x; | |
| B() : x(0) { std::cout << "B constructed with default c-tor at " << this << std::endl; } | |
| B(int new_x) : x(new_x) { std::cout << "B constructed with parametrized c-tor: " << *this << std::endl; } | |
| ~B() { std::cout << "Deleting B at " << this << "..." << std::endl; } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| //tworzymy i inicjalizujemy dwie zmienne o typie bool | |
| bool x {true}, y {false}; | |
| //tworzymy zmienną 'z' i inicjalizujemy ją zanegowaną wartoscią zmiennej x (czyli false) | |
| bool z {!x}; | |
| //przypisujemy zmiennej 'x' wartosc wyrazenia y OR z, czyli false (poniewaz ani y ani z nie mają wartosci true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| unsigned short x{1024}, y{0}; | |
| std::cout << "!x = " << !x << std::endl | |
| << "~x = " << ~x << std::endl; | |
| std::cout << "!y = " << !y << std::endl | |
| << "~y = " << ~y << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| unsigned short x{1024}, y{0}; | |
| std::cout << "!x = " << !x << std::endl | |
| << "~x = " << static_cast<unsigned short>(~x) << std::endl; | |
| std::cout << "!y = " << !y << std::endl | |
| << "~y = " << static_cast<unsigned short>(~y) << std::endl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| int x{10}, y{25}; | |
| std::cout << "x = " << x << ", y = " << y << std::endl | |
| << "x & y = " << (x & y) << std::endl | |
| << "x | y = " << (x | y) << std::endl | |
| << "x ^ y = " << (x ^ y) << std::endl; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| int main() { | |
| int x{0b10110}; | |
| std::cout << "x = " << x << std::endl | |
| << "x << 1 = " << (x << 1) << std::endl | |
| << "x << 2 = " << (x << 2) << std::endl | |
| << "x << 3 = " << (x << 3) << std::endl | |
| << "x >> 1 = " << (x >> 1) << std::endl |