├── .gitignore ├── README.md ├── Videos-Assignments ├── 17.cpp └── 20.cpp └── Website-Assignments ├── 1-8 ├── 1.cpp ├── 2.cpp ├── 3.cpp ├── 4.cpp └── 5.cpp ├── 9-15 ├── 1.cpp ├── 10.cpp ├── 11.cpp ├── 2.cpp ├── 3.cpp ├── 4.cpp ├── 5.cpp ├── 6.cpp ├── 7.cpp ├── 8.cpp └── 9.cpp ├── 16-23 ├── 1.cpp ├── 10.cpp ├── 11.cpp ├── 12.cpp ├── 2.cpp ├── 3.cpp ├── 4.cpp ├── 5.cpp ├── 6.cpp ├── 7.cpp ├── 8.cpp └── 9.cpp ├── 24-29 ├── 1.cpp ├── 2.cpp ├── 3.cpp ├── 4.cpp ├── 5.cpp ├── 6.cpp ├── 7.cpp └── 8.cpp ├── 30-35 ├── 1.cpp ├── 2.cpp ├── 3.cpp ├── 4.cpp ├── 5.cpp ├── 6.cpp └── 7.cpp ├── 36-37 ├── 1.cpp ├── 2.cpp └── 3.cpp └── 38-46 ├── 1.cpp ├── 10.cpp ├── 11.cpp ├── 12.cpp ├── 13.cpp ├── 2.cpp ├── 3.cpp ├── 4.cpp ├── 5.cpp ├── 6.cpp ├── 7.cpp ├── 8.cpp └── 9.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #

✨ Elzero C++ Assignments ✨

2 | 3 | 4 | 5 | --- 6 | 7 | ##

Important Instructions Before Beginning

8 | 9 | - You have to try to solve the assignments by yourself first, This repo is for helping you know what are you can't solve or for checking another solution only 10 | 11 | - Any issue in my answer please open a new issue and tag me to it and i will solve it ✔ 12 | 13 | --- 14 | 15 | ##

Important Notes From Videos

16 | 17 | 1. Data Size That Stored In RAM 18 | 19 | ```cpp 20 | #include 21 | using namespace std; 22 | 23 | int main () { 24 | cout << sizeof(1) << endl; // Int (4 Byte) 25 | cout << sizeof(1.1f) << endl; // Float (4 Byte) 26 | cout << sizeof(1.1) << endl; // Double (8 Byte) 27 | cout << sizeof(true) << endl; // Bool (1 Byte) 28 | cout << sizeof('a') << endl; // Char (1 Byte) 29 | } 30 | ``` 31 | 32 | --- 33 | 34 | ##

Progress

35 | 36 | * [X] Done 37 | * [ ] Will be done soon 38 | 39 | --- 40 | 41 | > Website Assignments 42 | 43 | * [X] Assignment From [1 - 8] 44 | * [X] Assignment From [9 - 15] 45 | * [X] Assignment From [16 - 23] 46 | * [X] Assignment From [24 - 29] 47 | * [X] Assignment From [30 - 35] 48 | * [X] Assignment From [36 - 37] 49 | * [X] Assignment From [38 - 46] 50 | * [ ] Assignment From [47 - 55] 51 | 52 | > Videos Assignments 53 | 54 | * [X] Assignment Video 17 55 | * [X] Assignment Video 20 56 | -------------------------------------------------------------------------------- /Videos-Assignments/17.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | double kilobytes; 6 | cout << "Enter A Number Of Kilobytes\n"; 7 | cin >> kilobytes; 8 | cout << "\n"; 9 | cout << "[1] " << kilobytes << " Kilobytes" << "\n"; 10 | cout << "[2] " << kilobytes * 1024 << " Bytes" << "\n"; 11 | cout << "[3] " << kilobytes * 1024 * 8 << " Bits"<< "\n"; 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /Videos-Assignments/20.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main () { 5 | int ascii; 6 | cout << "Enter an ASCII code : "; 7 | cin >> ascii; 8 | cout << endl; 9 | cout << "Character is : " << char(ascii) << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Website-Assignments/ 1-8/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Line One\n"; 6 | std::cout << "Line Two\n"; 7 | std::cout << "Line Three\n"; 8 | return 0; 9 | } -------------------------------------------------------------------------------- /Website-Assignments/ 1-8/2.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | iostream Header File Content 3 | -- cout 4 | -- cin 5 | -- cerr 6 | -- clog 7 | -- wcout 8 | -- wcin 9 | -- wcerr 10 | -- wclog 11 | */ -------------------------------------------------------------------------------- /Website-Assignments/ 1-8/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "Iam Learning Programming\nWith\nElzero\nWeb\nSchool\n<3"; 6 | return 0; 7 | } -------------------------------------------------------------------------------- /Website-Assignments/ 1-8/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | std::cout << "|=======================|\n"; 6 | std::cout << "|== Elzero Web School ==|\n"; 7 | std::cout << "|== C++ ==|\n"; 8 | std::cout << "|=======================|\n"; 9 | return 0; 10 | } -------------------------------------------------------------------------------- /Website-Assignments/ 1-8/5.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | This Is My First File 3 | In Learning Programming 4 | Iam Happy <3 5 | Iam Dragon 6 | */ 7 | 8 | #include // Preprocessor Directive 9 | 10 | int main() 11 | { 12 | std::cout /* Character Output */ << "Line One\n"; 13 | std::cout << "Line Two\n"; // cout Function 14 | std::cout << "Line Three\n"; 15 | // Return 0 16 | return 0; 17 | } // End Main Function -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Write Your Code Here 7 | int age = 40; 8 | int period = 10; 9 | 10 | // Do Not Edit The Next 2 Lines 11 | cout << "My Age Is: " << age << "\n"; 12 | cout << period << " Years Ago My Age Was: " << age - period << "\n"; 13 | 14 | // Add The Third Line Below 15 | cout << "After "<< period << " Years My Age Will Be: "<< age + period << "\n"; 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Write Your Code Here 7 | int one, two; 8 | cout << "Number One => "; 9 | cin >> one; 10 | cout << "\n"; 11 | cout << "Number Two => "; 12 | cin >> two; 13 | cout << "\n"; 14 | cout << "Needed Output " << one * two << " [" << one << " * " << two << "]"; 15 | 16 | // Number One => 10 17 | // Number Two => 100 18 | // Needed Output 1000 [10 * 100] 19 | return 0; 20 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/11.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | cout << "\"Bello\b\b\b\b\bHello Elzeroo\b"; 7 | cout << " Web Schoolll\b\b"; 8 | cout << " I Love Programming"; 9 | cout << " Too Much"; 10 | cout << " Specially C++\""; 11 | return 0; 12 | } 13 | 14 | // Needed Output 15 | // "Hello Elzero Web School I Love Programming Too Much Specially C++" -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Write Your One Line Code Here 7 | int a,b,c; 8 | 9 | // Do Not Edit Below 10 | a = 10, b = 20, c = 70; 11 | cout << "Sum Of All Number Is: " << a + b + c; 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/3.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | name [ Valid | Good Practice ] 3 | NAME [ Valid | Bad Practice ] 4 | 1name [ Not Valid ] 5 | __name [ Valid | Good Practice ] 6 | name@name [ Not Valid ] 7 | name10name [ Valid | Bad Practise ] 8 | name!name [ Not Valid ] 9 | first_NAME [ Valid | Bad Practice ] 10 | first_name [ Valid | Good Practice ] 11 | firstName [ Valid | Good Practice ] 12 | first name [ Not Valid ] 13 | fn [ Valid | Bad Practice ] 14 | public [ Not Valid ] 15 | Public [ Valid | Bad Practise ] 16 | */ -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Write my_text Variable Content Here 7 | string my_text = "============\n== Elzero ==\n============"; 8 | 9 | // Do Not Edit Below 10 | cout << my_text; 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Do Not Edit Below 7 | int a, b, c = 100; 8 | 9 | // Add Your Code Here 10 | a = b = c; 11 | 12 | // Do Not Edit Below 13 | cout << a + b + c; // 300 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Do Not Edit Below 7 | int a = 210, b = -50, c = -40; 8 | 9 | // Write Your cout Code Here 10 | cout << a - b - c; 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int num = 50; 5 | 6 | int read() 7 | { 8 | int num = 100; 9 | cout << num; 10 | return 0; 11 | } 12 | 13 | int play() 14 | { 15 | int num = 200; 16 | read(); 17 | return 0; 18 | } 19 | 20 | int main() 21 | { 22 | play(); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Edit Here To Fix The Error 7 | int current_year; 8 | int birth_year; 9 | 10 | // Do Not Edit Here 11 | current_year = 2022; 12 | birth_year = 1982; 13 | int age_in_years = current_year - birth_year; 14 | cout << age_in_years; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Website-Assignments/ 9-15/9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Write Your Code Here 7 | int num; 8 | cout << "Num "; 9 | cin >> num; 10 | cout << "\n"; 11 | cout << "Needed Output "<< num * num << " [" << num << " * " << num << "]"; 12 | 13 | // Num 10 14 | // Needed Output 100 [10 * 10] 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/1.cpp: -------------------------------------------------------------------------------- 1 | // Example 2 | false // bool => Boolean 3 | 4 | 'a' // char => Character 5 | '9' // char => Character 6 | 9 // int => Integer 7 | true // bool => Boolean 8 | 100 // int => Integer 9 | -10 // int => Integer 10 | 0 // int => Integer 11 | false // bool => Boolean 12 | 10.9 // double => Double -------------------------------------------------------------------------------- /Website-Assignments/16-23/10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Add Type Alias Here 6 | // First 7 | using lli = long long int; 8 | // Second 9 | typedef long long int lli; 10 | 11 | // Do Not Edit 12 | lli num = 150050005; // This Is Long Long Int 13 | cout << num << "\n"; // 150050005 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/11.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Do Not Edit Here 6 | short int a = 100; 7 | float b = 98.5f; 8 | double c = 1.7; 9 | 10 | // Edit This Line And Use Type Casting To Get The Output 11 | cout << a + int(b) + sizeof(short(c)) << "\n"; // 200 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /Website-Assignments/16-23/12.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Do Not Edit Here 6 | short a = 1000; 7 | int b = 10000; 8 | long double c = 5.560000505012; 9 | 10 | // Change ??? To Something Else To Get The Output 11 | cout << sizeof(c) - sizeof(b) << "\n"; // 12 12 | cout << sizeof(b) + sizeof(c) << "\n"; // 20 13 | cout << sizeof(a) * sizeof(c) << "\n"; // 32 14 | cout << a * int(c) << "\n"; // 5000 15 | cout << char(sizeof(c) * int(c)) << "\n"; // P 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | double salary = 5000.98; 6 | // 8 Bytes 7 | cout << sizeof(salary) << endl; 8 | // 64 Bits 9 | cout << sizeof(salary) * 8 << endl; 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | // Output Needed 7 | // "Maximum Integer Number Is => 2147483647" 8 | cout << "Maximum Integer Number Is => " << INT_MAX << endl; 9 | // "Minimum Integer Number Is => -2147483648" 10 | cout << "Minimum Integer Number Is => " << INT_MIN << endl; 11 | // "Maximum Short Integer Number Is => 32767" 12 | cout << "Maximum Short Integer Number Is => " << SHRT_MAX << endl; 13 | // "Minimum Short Integer Number Is => -32768" 14 | cout << "Minimum Short Integer Number Is => " << SHRT_MIN << endl; 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Edit Line To Make 8 Become 4 6 | cout << sizeof(int(10.5) + 5 + int(20.5) + 10) << "\n"; // 8 7 | 8 | return 0; 9 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | char a = '~'; 6 | char b = '&'; 7 | char c = '%'; 8 | char d = 'A'; 9 | 10 | // Output Needed 11 | // "ASCII Value of ~ Is 126" 12 | cout << "ASCII Value of " << a << " Is " << int(a) << endl; 13 | // "ASCII Value of & Is 38" 14 | cout << "ASCII Value of " << b << " Is " << int(b) << endl; 15 | // "ASCII Value of % Is 37" 16 | cout << "ASCII Value of " << c << " Is " << int(c) << endl; 17 | // "ASCII Value of A Is 65" 18 | cout << "ASCII Value of " << d << " Is " << int(d) << endl; 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Website-Assignments/16-23/6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a = 69; 6 | int b = 108; 7 | int c = 122; 8 | int d = 101; 9 | int e = 114; 10 | int f = 111; 11 | 12 | // Output Needed 13 | // "Character Of This ASCII Value 69 Is E" 14 | cout << "Character Of This ASCII Value " << a << " Is " << char(a) << endl; 15 | // "Character Of This ASCII Value 108 Is l" 16 | cout << "Character Of This ASCII Value " << b << " Is " << char(b) << endl; 17 | // "Character Of This ASCII Value 122 Is z" 18 | cout << "Character Of This ASCII Value " << c << " Is " << char(c) << endl; 19 | // "Character Of This ASCII Value 101 Is e" 20 | cout << "Character Of This ASCII Value " << d << " Is " << char(d) << endl; 21 | // "Character Of This ASCII Value 114 Is r" 22 | cout << "Character Of This ASCII Value " << e << " Is " << char(e) << endl; 23 | // "Character Of This ASCII Value 111 Is o" 24 | cout << "Character Of This ASCII Value " << f << " Is " << char(f) << endl; 25 | 26 | // Output Needed In Last Line 27 | // "Elzero" 28 | cout << char(a) << char(b) << char(c) << char(d) << char(e) << char(f); 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a = 1; 6 | int b = 13; 7 | int c = 17; 8 | int d = 70; 9 | 10 | // Output Needed 11 | // "EWS" 12 | cout << char(d - a) << char(d + c) << char(d + b); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | 6 | // Edit Anything Except Values 7 | short a = 100; 8 | double b = 15001500; 9 | long double c = 100.54565746; 10 | 11 | // Do Not Edit 12 | cout << sizeof(a) << " Bytes\n"; // 2 Bytes 13 | cout << sizeof(b) << " Bytes\n"; // 8 Bytes 14 | cout << sizeof(c) << " Bytes\n"; // 16 Bytes 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Website-Assignments/16-23/9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | 6 | // Edit Anything Except Values 7 | int a = 100; 8 | int b = -100; 9 | short c = 100; 10 | double d = 500.550; 11 | 12 | // Do Not Edit 13 | cout << a << "\n"; // 100 14 | cout << b << "\n"; // -100 15 | cout << c << "\n"; // 100 16 | cout << d << "\n"; // 500.550 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /Website-Assignments/24-29/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int num = 3; 6 | 7 | cout << num + num << "\n"; // 6 8 | cout << (num + num) + (num % num) << "\n"; // 6 9 | cout << (num * num) - num << "\n"; // 6 10 | cout << (num + num + num) - num << "\n"; // 6 11 | cout << (num - num) + (num + num) << "\n"; // 6 12 | cout << (num == num) * (num + num) << "\n"; // 6 13 | cout << (num > num) + (num + num) << "\n"; // 6 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Website-Assignments/24-29/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << 10 * 20 * 15 * 3 * 190 * 10 % 400 << "\n"; // 0 6 | 7 | return 0; 8 | } -------------------------------------------------------------------------------- /Website-Assignments/24-29/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Do Not Edit 6 | int num = 3; 7 | 8 | /* 9 | Write Code Here 10 | Do Not Use num = 6 :) 11 | */ 12 | 13 | num += num; 14 | 15 | // Do Not Edit 16 | cout << num << "\n"; // 6 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Website-Assignments/24-29/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | cout << (int(10.5) * 5) + int(40.5 + 10.1) << "\n"; // 100 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /Website-Assignments/24-29/5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | // Assign The Values 7 | char a = 'd'; 8 | char b = '\n'; 9 | char c = 'Z'; 10 | 11 | // Do Not Edit 12 | cout << b * c + a << "\n"; // 10 * 90 + 100 = 1000 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /Website-Assignments/24-29/6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | /* 6 | We Need To Use This Operators In Solutions 7 | - && 8 | -- >= 9 | -- <= 10 | -- > 11 | -- < 12 | -- == 13 | -- ! 14 | - || 15 | */ 16 | 17 | int a = 10; 18 | int b = 25; 19 | int c = 15; 20 | 21 | cout << (a < b) << "\n"; // True 22 | cout << (c > a) << "\n"; // True 23 | cout << (a + c == b) << "\n"; // True 24 | cout << (c >= a) << "\n"; // True 25 | cout << (c <= b) << "\n"; // True 26 | cout << (b && a && b && c) << "\n"; // True 27 | cout << !(a > b) << "\n"; // True 28 | cout << (a || b || b || a) << "\n"; // True 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /Website-Assignments/24-29/7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a = 10; 6 | int b = 20; 7 | 8 | cout << ((a + b) * (a + b) + a * a) * a << "\n"; // 10000 9 | 10 | // Hint For Help 11 | cout << 10 + 5 * 20 << "\n"; // 5 * 20 = 100 + 10 = 110 12 | cout << (10 + 5) * 20 << "\n"; // 10 + 5 = 15 * 20 = 300 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Website-Assignments/24-29/8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int num = 10; 6 | cout << --num << " | " << num << " | " << ++++num << "\n"; // 9 | 9 | 11 7 | cout << num << " | " << ++num << " | " << num << "\n"; // 11 | 12 | 12 8 | cout << --num << " | " << --num << " | " << --num << "\n"; // 11 | 10 | 9 9 | 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Website-Assignments/30-35/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int age = 40; 6 | int points = 800; 7 | float rate = 8.5f; 8 | 9 | // Your Condition Here 10 | if (age > 18 && points > 500 && rate > 5) 11 | cout << "Yes Age > 18 & Points > 500 & Rate > 5"; 12 | 13 | // Output Needed If All Conditions Is True 14 | // "Yes Age > 18 & Points > 500 & Rate > 5" 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Website-Assignments/30-35/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Test Case 1 6 | int age = 18; 7 | int points = 450; 8 | 9 | // Output 10 | // "No Age Is Not Ok" 11 | // "No Points Is Not Ok" 12 | 13 | // Test Case 2 14 | int age = 20; 15 | int points = 450; 16 | 17 | // Output 18 | // "Yes Age Is Ok" 19 | // "No Points Is Not Ok" 20 | 21 | // Test Case 3 22 | int age = 20; 23 | int points = 650; 24 | 25 | // Output 26 | // "Yes Age Is Ok" 27 | // "Yes Points Is Ok" 28 | 29 | if (age > 18) 30 | { 31 | cout << "Yes Age Is Ok" << endl; 32 | 33 | if (points > 500) 34 | { 35 | cout << "Yes Points Is Ok" << endl; 36 | } 37 | else 38 | { 39 | cout << "No Points Is Not Ok" << endl; 40 | } 41 | } 42 | else 43 | { 44 | cout << "No Age Is Not Ok" << endl; 45 | 46 | if (points > 500) 47 | { 48 | cout << "Yes Points Is Ok" << endl; 49 | } 50 | else 51 | { 52 | cout << "No Points Is Not Ok" << endl; 53 | } 54 | } 55 | 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /Website-Assignments/30-35/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int num; 6 | cout << "Please Type A Number Between 0 And 150\n"; 7 | cin >> num; 8 | 9 | if (num < 10) 10 | { 11 | cout << "00" << num; 12 | } 13 | else if (num > 10 && num < 100) 14 | { 15 | cout << "0" << num; 16 | } 17 | else 18 | { 19 | cout << num; 20 | } 21 | 22 | // If Number Smaller Than 10 "Example 5" Output Will Be => 005 23 | // If Number Larger Than 10 And Smaller Than 100 "Example 59" Output Will Be => 059 24 | // If Number Larger Than 100 "Example 115" Output Will Be => 115 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /Website-Assignments/30-35/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int num1 = 11; 6 | int num2 = 10; 7 | int num3 = 11; 8 | int num4 = 33; 9 | 10 | // Do Not Edit Any Condition 11 | 12 | // Condition 1 13 | if (num1 > num2) 14 | cout << "Condition 1 Is True\n"; 15 | else 16 | cout << "Condition 1 Is False\n"; 17 | 18 | // Condition 2 19 | if (num1 > num2 && num1 < num4) 20 | cout << "Condition 2 Is True\n"; 21 | else 22 | cout << "Condition 2 Is False\n"; 23 | 24 | // Condition 3 25 | if (num1 > num2 && num1 == num3) 26 | cout << "Condition 3 Is True\n"; 27 | else 28 | cout << "Condition 3 Is False\n"; 29 | 30 | // Condition 4 31 | if (num1 + num2 < num4) 32 | cout << "Condition 4 Is True\n"; 33 | else 34 | cout << "Condition 4 Is False\n"; 35 | 36 | // Condition 5 37 | if (num1 + num3 < num4) 38 | cout << "Condition 5 Is True\n"; 39 | else 40 | cout << "Condition 5 Is False\n"; 41 | 42 | // Condition 6 43 | if (num1 + num2 + num3 < num4) 44 | cout << "Condition 6 Is True\n"; 45 | else 46 | cout << "Condition 6 Is False\n"; 47 | 48 | // Condition 7 49 | if (num4 - (num1 + num3) + num2 == 21) 50 | cout << "Condition 7 Is True\n"; 51 | else 52 | cout << "Condition 7 Is False\n"; 53 | 54 | // Output Needed 55 | // "Condition 1 Is True" 56 | // "Condition 2 Is True" 57 | // "Condition 3 Is True" 58 | // "Condition 4 Is True" 59 | // "Condition 5 Is True" 60 | // "Condition 6 Is True" 61 | // "Condition 7 Is True" 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /Website-Assignments/30-35/5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int by = 82; // by => Birth Year 6 | int s = 500; // s => Salary 7 | if (by > 80) 8 | { 9 | if (s < 600) 10 | cout << "Ok\n"; 11 | else 12 | cout << "High\n"; 13 | } 14 | else 15 | { 16 | cout << "Not Ok\n"; 17 | } 18 | 19 | cout << (by > 80 ? (s < 600) ? "Ok\n" : "High\n" : "Not Ok\n" ); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Website-Assignments/30-35/6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int age = 40; 6 | int points = 100; 7 | 8 | if (age > 18 && points > 50 && sizeof(age) == 4) 9 | { 10 | cout << "Age Data Is 4 Bytes\n"; 11 | cout << "Age Is Ok\n"; 12 | cout << "Points Is Ok\n"; 13 | } 14 | 15 | // Output Needed 16 | // "Age Data Is 4 Bytes" 17 | // "Age Is Ok" 18 | // "Points Is Ok" 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /Website-Assignments/30-35/7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int result = 0; 6 | int num1, num2, num3, num4; 7 | cout << "Please Type 4 Number In A Row\n"; 8 | cout << "Only Even Numbers Smaller Than 20 Will Be Counted\n"; 9 | cin >> num1 >> num2 >> num3 >> num4; 10 | 11 | if (num1 < 20 && num1 % 2 == 0) 12 | result += num1; 13 | 14 | if (num2 < 20 && num2 % 2 == 0) 15 | result += num2; 16 | 17 | if (num3 < 20 && num3 % 2 == 0) 18 | result += num3; 19 | 20 | if (num4 < 20 && num4 % 2 == 0) 21 | result += num4; 22 | 23 | cout << result << endl; 24 | 25 | /* 26 | Test Case 1 27 | Numbers => 15, 16, 22, 8 28 | Result => 24 29 | 30 | "Explain" 31 | Starting Result Is 0 32 | [Number 1] 15 => Not Even Number 33 | [Number 2] 16 => Smaller Than 20 And Even Number 34 | 0 + 16 = 16 35 | [Number 3] 22 => Not Smaller Than 20 36 | [Number 4] 8 => Smaller Than 20 And Even Number 37 | 16 + 8 = 24 38 | 39 | ================================= 40 | 41 | Test Case 2 42 | Numbers => 100, 11, 12, 18 43 | Result => 30 44 | 45 | "Explain" 46 | Starting Result Is 0 47 | [Number 1] 100 => Not Smaller Than 20 48 | [Number 2] 11 => Not Even Number 49 | [Number 3] 12 => Smaller Than 20 And Even Number 50 | 0 + 12 = 12 51 | [Number 4] 18 => Smaller Than 20 And Even Number 52 | 12 + 18 = 30 53 | */ 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /Website-Assignments/36-37/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | 6 | int year; 7 | 8 | cin >> year; 9 | cout << endl; 10 | 11 | switch(year) { 12 | case 1982: 13 | cout << "My Birth Day" << endl; 14 | break; 15 | case 1989: 16 | cout << "My First Work" << endl; 17 | break; 18 | case 1995: 19 | cout << "Windows 95" << endl; 20 | break; 21 | case 2000: 22 | cout << "Windows Millennium" << endl; 23 | break; 24 | case 2002: 25 | cout << "Created My vBulletin Forum" << endl; 26 | break; 27 | default: 28 | cout << "No Events in This Year" << endl; 29 | } 30 | 31 | /* 32 | 1982 => "My Birth Day" 33 | 1989 => "My First Work" 34 | 1995 => "Windows 95" 35 | 2000 => "Windows Millennium" 36 | 2002 => "Created My vBulletin Forum" 37 | Any Other Year => "No Events in This Year" 38 | */ 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Website-Assignments/36-37/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int day; 7 | cin >> day; 8 | 9 | switch (day) 10 | { 11 | case 1: 12 | case 2: 13 | case 3: 14 | cout << day << " Shop Is Open"; 15 | break; 16 | case 4: 17 | case 5: 18 | cout << day << " Shop Is Closed"; 19 | break; 20 | default: 21 | cout << "Day Is Not Valid"; 22 | } 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Website-Assignments/36-37/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int num; 7 | cin >> num; 8 | 9 | switch(num) { 10 | case 10: 11 | cout << "Case 1"; 12 | break; 13 | case 20: 14 | cout << "Case 2"; 15 | break; 16 | case 30: 17 | case 31: 18 | case 32: 19 | cout << "Case 3"; 20 | break; 21 | default: 22 | cout << "Invalid Number"; 23 | } 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int nums[]{100, 300, 600, 900}; 6 | string awards[]{"iPhone", "iPad", "PC", "Car"}; 7 | 8 | cout << "Number " << nums[0] << " Award Is: " << awards[0] << endl; 9 | cout << "Number " << nums[1] << " Award Is: " << awards[1] << endl; 10 | cout << "Number " << nums[2] << " Award Is: " << awards[2] << endl; 11 | cout << "Number " << nums[3] << " Award Is: " << awards[3] << endl; 12 | 13 | // Output Needed 14 | // "Number 100 Award Is: iPhone" 15 | // "Number 300 Award Is: iPad" 16 | // "Number 600 Award Is: PC" 17 | // "Number 900 Award Is: Car" 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | array nums = {10, 20, 30, 40, 20, 50}; 8 | 9 | // Method 1 10 | cout << "First: " << nums[0] << endl; 11 | cout << "Last: " << nums[nums.size() - 1] << endl; 12 | // "First: 10" 13 | // "Last: 50" 14 | 15 | // Method 2 16 | cout << "First: " << nums.front() << endl; 17 | cout << "Last: " << nums.back() << endl; 18 | // "First: 10" 19 | // "Last: 50" 20 | 21 | // Method 3 22 | cout << "First: " << nums.at(0) << endl; 23 | cout << "Last: " << nums.at(size(nums) - 1) << endl; 24 | // "First: 10" 25 | // "Last: 50" 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/11.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | // Do Not Edit The Next 3 Lines 9 | int index = 1; 10 | array oldNums = {10, 20, 30}; 11 | array newNums; 12 | 13 | // Write Your Code Here 14 | newNums = oldNums; 15 | reverse(begin(newNums), end(newNums)); 16 | 17 | // Do Not Edit The Next 3 Lines 18 | cout << newNums[0] << "\n"; // 30 19 | cout << newNums[1] << "\n"; // 20 20 | cout << newNums[2] << "\n"; // 10 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/12.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Do Not Edit The Next 6 Lines 6 | int nums[] = {1, 2, 3, 5}; 7 | int vals[] = {10, 20, 40, 30, 10, 60}; 8 | int i1 = nums[3]; 9 | int i2 = nums[0]; 10 | int i3 = nums[1]; 11 | int i4 = nums[2]; 12 | 13 | // Need To Get Ouput 150 14 | // You Can Use Plus Operator Only 15 | 16 | // Your Code Here 17 | cout << vals[i1] + vals[i2] + vals[i3] + vals[i4]; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/13.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | string fName = "Elzero "; 6 | string mName = "Web "; 7 | string lName = "School"; 8 | 9 | cout << fName + mName + lName << endl; 10 | cout << fName << mName << lName << endl; 11 | cout << fName.append(mName).append(lName) << endl; 12 | 13 | // Output Needed 14 | // "Elzero Web School" 15 | // "Elzero Web School" 16 | // "Elzero Web School" 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Example 1 6 | int check = 25; 7 | int nums[]{40, 20, 30, 70, 100}; 8 | 9 | // Ouput 10 | // "{40} + {70} = 110" 11 | 12 | // Example 2 13 | int check = 25; 14 | int nums[]{20, 35, 30, 70, 100}; 15 | 16 | // Ouput 17 | // "{35} + {70} = 105" 18 | 19 | // Example 3 20 | int check = 25; 21 | int nums[]{20, 25, 30, 70, 100}; 22 | 23 | // Ouput 24 | // "{30} + {70} = 100" 25 | 26 | if (nums[0] > check) 27 | { 28 | cout << "{" << nums[0] << "}" << " + " << "{" << nums[3] << "}"; 29 | cout << " = "; 30 | cout << nums[0] + nums[3]; 31 | } 32 | else if (nums[1] > check) 33 | { 34 | cout << "{" << nums[1] << "}" << " + " << "{" << nums[3] << "}"; 35 | cout << " = "; 36 | cout << nums[1] + nums[3]; 37 | } 38 | else if (nums[2] > check) 39 | { 40 | cout << "{" << nums[2] << "}" << " + " << "{" << nums[3] << "}"; 41 | cout << " = "; 42 | cout << nums[2] + nums[3]; 43 | } 44 | 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int filling = 10; 6 | int vals[]{100, 200, 300, 400}; 7 | 8 | // Write One Line Of Code Here To Fill Array Value With Number 10 9 | vals[0] = vals[1] = vals[2] = vals[3] = filling; 10 | 11 | cout << vals[0] << "\n"; // 10 12 | cout << vals[1] << "\n"; // 10 13 | cout << vals[2] << "\n"; // 10 14 | cout << vals[3] << "\n"; // 10 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Example 1 6 | int vals[]{100, 200, 250, 400, 200}; 7 | 8 | // Needed Output 9 | // "First Number + Last Number Is Larger Than Middle Number" 10 | // "100 + 200 = 300" 11 | // "300 > 250" 12 | 13 | // Example 2 14 | int vals[]{100, 200, 500, 400, 200}; 15 | 16 | // Needed Output 17 | // "Second Number + Before Last Number Is Larger Than Middle Number" 18 | // "200 + 400 = 600" 19 | // "600 > 500" 20 | 21 | // Example 3 22 | int vals[]{100, 200, 600, 400, 200}; 23 | 24 | // Needed Output 25 | // "Middle Number Is The Largest" 26 | // "600" 27 | 28 | if (vals[0] + vals[4] > vals[2]) 29 | { 30 | cout << "Second Number + Before Last Number Is Larger Than Middle Number" << endl; 31 | cout << vals[0] << " + " << vals[4] << " = " << vals[0] + vals[4] << endl; 32 | cout << vals[0] + vals[4] << " > " << vals[2] << endl; 33 | } 34 | else if (vals[1] + vals[3] > vals[2]) 35 | { 36 | cout << "Second Number + Before Last Number Is Larger Than Middle Number" << endl; 37 | cout << vals[1] << " + " << vals[3] << " = " << vals[1] + vals[3] << endl; 38 | cout << vals[1] + vals[3] << " > " << vals[2] << endl; 39 | } 40 | else 41 | { 42 | cout << "Middle Number Is The Largest" << endl; 43 | cout << vals[2] << endl; 44 | } 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Example 1 6 | int vals[] = {100, 200, 600, 200, 100}; 7 | 8 | // Output 9 | // "Array Is Palindrome" 10 | 11 | // Example 2 12 | int vals[] = {100, 200, 200, 100}; 13 | 14 | // Output 15 | // "Array Is Palindrome" 16 | 17 | // Example 3 18 | int vals[] = {100, 300, 600, 200, 100}; 19 | 20 | // Output 21 | // "Array Is Not Palindrome" 22 | 23 | int last = sizeof(vals) / sizeof(vals[0]) - 1; 24 | if (vals[0] == vals[last] && vals[1] == vals[last - 1]) 25 | { 26 | cout << "Array Is Palindrome" << endl; 27 | } 28 | else 29 | { 30 | cout << "Array Is Not Palindrome" << endl; 31 | } 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int vals[] = {10, 20, 30}; 6 | 7 | // Write Your Code Here 8 | vals[0] = 100; 9 | vals[1] = 200; 10 | vals[2] = 300; 11 | vals[3] = 400; 12 | 13 | cout << vals[0] << "\n"; // 100 14 | cout << vals[1] << "\n"; // 200 15 | cout << vals[2] << "\n"; // 300 16 | cout << vals[3] << "\n"; // 400 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | // Create The Array Here 6 | string names[3][3] = { 7 | {"Ahmed", "Sayed", "Mahmoud"}, 8 | {"Sameh", "Mahdy", "Gamal"}, 9 | {"Mohamed", "Adel", "Majed"} 10 | }; 11 | 12 | cout << "First Collection Of Names:\n"; 13 | cout << names[0][0] << "\n"; // Ahmed 14 | cout << names[1][1] << "\n"; // Mahdy 15 | cout << names[2][2] << "\n"; // Majed 16 | 17 | cout << "Second Collection Of Names:\n"; 18 | cout << names[2][1] << "\n"; // Adel 19 | cout << names[1][2] << "\n"; // Gamal 20 | cout << names[0][2] << "\n"; // Mahmoud 21 | 22 | cout << "Third Collection Of Names:\n"; 23 | cout << names[0][1] << "\n"; // Sayed 24 | cout << names[1][0] << "\n"; // Sameh 25 | cout << names[2][0] << "\n"; // Mohamed 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() { 6 | // Your Code Here 7 | array nums = {1, 2, 3}; 8 | 9 | // Do Not Edit 10 | nums.fill(100); 11 | cout << nums[0] << "\n"; // 100 12 | cout << nums[1] << "\n"; // 100 13 | cout << nums[2] << "\n"; // 100 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Website-Assignments/38-46/9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int nums[] = {10, 20, 30, 40, 20, 50}; 6 | 7 | // Method 1 8 | cout << sizeof(nums) / sizeof(nums[0]) << endl; 9 | // 6 10 | 11 | // Method 2 12 | cout << size(nums) << endl; 13 | // 6 14 | 15 | // Method 3 16 | cout << end(nums) - begin(nums) << endl; 17 | // 6 18 | 19 | return 0; 20 | } 21 | --------------------------------------------------------------------------------