├── Apna College C++ ├── Awesome Pattern Questions │ ├── problem1.cpp │ ├── problem1.exe │ ├── problem10.cpp │ ├── problem10.exe │ ├── problem11.cpp │ ├── problem11.exe │ ├── problem12.cpp │ ├── problem12.exe │ ├── problem13.cpp │ ├── problem13.exe │ ├── problem14.cpp │ ├── problem14.exe │ ├── problem15.cpp │ ├── problem15.exe │ ├── problem16.cpp │ ├── problem16.exe │ ├── problem2.cpp │ ├── problem2.exe │ ├── problem3.cpp │ ├── problem3.exe │ ├── problem4.cpp │ ├── problem4.exe │ ├── problem5.cpp │ ├── problem5.exe │ ├── problem6.cpp │ ├── problem6.exe │ ├── problem7.cpp │ ├── problem7.exe │ ├── problem8.cpp │ ├── problem8.exe │ ├── problem9.cpp │ └── problem9.exe ├── Functions Questions │ ├── problem1.cpp │ ├── problem1.exe │ ├── problem2.cpp │ ├── problem2.exe │ ├── problem4.cpp │ ├── problem4.exe │ ├── problem5.cpp │ └── problem5.exe ├── tut1_Forloop.cpp ├── tut1_Forloop.exe ├── tut2_whileloop.cpp ├── tut2_whileloop.exe ├── tut3_dowhileloop.cpp ├── tut3_dowhileloop.exe ├── tut4_break_and_continue.cpp ├── tut4_break_and_continue.exe ├── tut5_switchcase.cpp ├── tut5_switchcase.exe ├── tut6_functions.cpp └── tut6_functions.exe ├── Code With Harry ├── Helloworld.cpp ├── Helloworld.exe ├── tut10.cpp ├── tut10.exe ├── tut11.cpp ├── tut11.exe ├── tut4.cpp ├── tut4.exe ├── tut5.cpp ├── tut5.exe ├── tut6.cpp ├── tut6.exe ├── tut7.cpp ├── tut7.exe ├── tut9.cpp └── tut9.exe ├── Coding Problems ├── problem1.cpp ├── problem1.exe ├── problem2.cpp ├── problem2.exe ├── problem3.cpp ├── problem3.exe ├── problem4.cpp ├── problem4.exe ├── problem5.cpp ├── problem5.exe ├── problem6.cpp ├── problem6.exe ├── problem7.cpp ├── problem8.cpp └── problem8.exe └── README.md /Apna College C++/Awesome Pattern Questions/problem1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | for (int i = 1; i <= 5; i++) 7 | { 8 | for (int j = 1; j <= 4; j++) 9 | { 10 | cout << "*"; 11 | } 12 | cout << endl; 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem1.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | 9 | for (int i = 1; i <= n; i++) 10 | { 11 | for (int j = 1; j <= i; j++) 12 | { 13 | if ((i + j) % 2 == 0) 14 | { 15 | cout << 1 << " "; 16 | } 17 | else 18 | { 19 | cout << 0 << " "; 20 | } 21 | } 22 | cout << endl; 23 | } 24 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem10.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem10.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem11.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | int n; 8 | cin >> n; 9 | 10 | for (int i = n; i >= 1; i--) 11 | { 12 | for (int j = i; j >= 0; j--) 13 | { 14 | cout << " "; 15 | } 16 | for (int k = 1; k <= n; k++) 17 | { 18 | cout << "* "; 19 | } 20 | cout << endl; 21 | } 22 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem11.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem11.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem12.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | int n; 8 | cin >> n; 9 | for (int i = 1; i <= n; i++) 10 | { 11 | for (int j = 1; j <= (n - i); j++) 12 | { 13 | cout << " "; 14 | } 15 | for (int k = 1; k <= i; k++) 16 | { 17 | cout << k << " "; 18 | } 19 | cout << endl; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem12.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem12.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem13.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | int n; 8 | cin >> n; 9 | 10 | for (int i = 1; i <= n; i++) 11 | { 12 | for (int j = (n - i); j >= 1; j--) 13 | { 14 | cout << " "; 15 | } 16 | for (int k = i; k >= 1; k--) 17 | { 18 | cout << k << " "; 19 | } 20 | for (int l = 2; l <= i; l++) 21 | { 22 | cout << l << " "; 23 | } 24 | cout << endl; 25 | } 26 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem13.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem13.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem14.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | int n; 8 | cin >> n; 9 | 10 | for (int i = 1; i <= n; i++) 11 | { 12 | for (int j = (n - i); j >= 1; j--) 13 | { 14 | cout << " "; 15 | } 16 | for (int k = 1; k <= (2 * i - 1); k++) 17 | { 18 | cout << "*"; 19 | } 20 | cout << endl; 21 | } 22 | 23 | for (int i = n; i >= 1; i--) 24 | { 25 | for (int j = 1; j <= (n - i); j++) 26 | { 27 | cout << " "; 28 | } 29 | for (int k = 1; k <= (2 * i - 1); k++) 30 | { 31 | cout << "*"; 32 | } 33 | cout << endl; 34 | } 35 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem14.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem14.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem15.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | int n, reverse = 0; 8 | cin >> n; 9 | while (n > 0) 10 | { 11 | int lastdigit = n % 10; 12 | reverse = reverse * 10 + lastdigit; 13 | n = n / 10; 14 | } 15 | 16 | cout << reverse; 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem15.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem15.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | 8 | int n, sum = 0; 9 | cin >> n; 10 | int originaln = n; 11 | while (n > 0) 12 | { 13 | int remainder = n % 10; 14 | sum = sum + remainder * remainder * remainder; 15 | n = n / 10; 16 | } 17 | cout << sum; 18 | if (originaln == sum) 19 | { 20 | cout << "Armstrong"; 21 | } 22 | else 23 | { 24 | cout << "Not Armstrong"; 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem16.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem16.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int row, column; 7 | cin >> row >> column; 8 | 9 | for (int i = 1; i <= row; i++) 10 | { 11 | for (int j = 1; j <= column; j++) 12 | { 13 | if (i == 1 || i == row || j == 1 || j == column) 14 | { 15 | cout << "*"; 16 | } 17 | else 18 | { 19 | cout << " "; 20 | } 21 | } 22 | cout << endl; 23 | } 24 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem2.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | //My Solution 7 | // int rows, n; 8 | // cout << "Enter the number of rows" << endl; 9 | // cin >> rows; 10 | // n = rows; 11 | 12 | // for (int i = 1; i <= rows; i++) 13 | // { 14 | // for (int j = n; j >= 1; --j) 15 | // { 16 | // cout << "*"; 17 | // } 18 | // n--; 19 | // cout << endl; 20 | // } 21 | 22 | //Ideal Solutioon 23 | 24 | int n; 25 | cin >> n; 26 | 27 | for (int i = n; i >= 1; i--) 28 | { 29 | for (int j = 1; j <= i; j++) 30 | { 31 | cout << "*"; 32 | } 33 | cout << endl; 34 | } 35 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem3.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | for (int i = n; i >= 1; i--) 9 | { 10 | for (int j = 1; j <= n; j++) 11 | { 12 | if (j >= i) 13 | { 14 | cout << "* "; 15 | } 16 | else 17 | { 18 | cout << " "; 19 | } 20 | } 21 | cout << endl; 22 | } 23 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem4.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | 9 | for (int i = 1; i <= n; i++) 10 | { 11 | for (int j = 1; j <= i; j++) 12 | { 13 | cout << i; 14 | } 15 | cout << endl; 16 | } 17 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem5.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem6.cpp: -------------------------------------------------------------------------------- 1 | //Floyd's Triangle 2 | 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | int n, s; 9 | s = 1; 10 | cin >> n; 11 | for (int i = 1; i <= n; i++) 12 | { 13 | for (int j = 1; j <= i; j++) 14 | { 15 | cout << s << " "; 16 | s++; 17 | } 18 | cout << endl; 19 | } 20 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem6.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem7.cpp: -------------------------------------------------------------------------------- 1 | //Butterfly Pattern 2 | 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | for (int i = 1; i <= 4; i++) 9 | { 10 | for (int j = 1; j <= 8; j++) 11 | { 12 | if (j <= i || j >= (9 - i)) 13 | { 14 | cout << "* "; 15 | } 16 | else 17 | { 18 | cout << " "; 19 | } 20 | } 21 | cout << endl; 22 | } 23 | for (int i = 4; i >= 1; i--) 24 | { 25 | for (int j = 1; j <= 8; j++) 26 | { 27 | if (j <= i || j >= (9 - i)) 28 | { 29 | cout << "* "; 30 | } 31 | else 32 | { 33 | cout << " "; 34 | } 35 | } 36 | cout << endl; 37 | } 38 | } 39 | 40 | // #include 41 | // using namespace std; 42 | 43 | // int main() 44 | // { 45 | // int n; 46 | // cin >> n; 47 | 48 | // for (int i = 1; i < n; i++) 49 | // { 50 | // for (int j = 1; j < 2 * n - 1; j++) 51 | // { 52 | // if (i >= j || i > 2 * n - 2 - j) 53 | // { 54 | // cout << "* "; 55 | // } 56 | // else 57 | // { 58 | // cout << " "; 59 | // } 60 | 61 | // // } 62 | // // cout<=1;i--){ 65 | // // for(int j=1 ;j<2*n-1;j++) 66 | // // { 67 | // // if(i>=j ||i>2*n-2-j ) 68 | // // { 69 | // // cout<<"* "; 70 | // // } 71 | // // else{ 72 | // // cout<<" "; 73 | // // } 74 | // // } 75 | // // cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | for (int i = 1; i <= 4; i++) 8 | { 9 | for (int j = 1; j <= i; j++) 10 | { 11 | cout << " *"; 12 | } 13 | cout << endl; 14 | } 15 | for (int i = 3; i >= 1; i--) 16 | { 17 | for (int j = 1; j <= i; j++) 18 | { 19 | cout << " *"; 20 | } 21 | cout << endl; 22 | } 23 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem8.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem8.exe -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | for (int i = n; i >= 1; i--) 9 | { 10 | for (int j = 1; j <= i; j++) 11 | { 12 | cout << j << " "; 13 | n++; 14 | } 15 | cout << endl; 16 | } 17 | } -------------------------------------------------------------------------------- /Apna College C++/Awesome Pattern Questions/problem9.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Awesome Pattern Questions/problem9.exe -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem1.cpp: -------------------------------------------------------------------------------- 1 | //print all prime numbers between 2 given numbers 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | bool checkprime(int number) 7 | { 8 | 9 | for (int j = 2; j <= sqrt(number); j++) 10 | { 11 | 12 | if (number % j == 0) 13 | { 14 | return false; 15 | } 16 | } 17 | return true; 18 | } 19 | 20 | int main() 21 | { 22 | 23 | int num1, num2; 24 | cin >> num1 >> num2; 25 | for (int i = num1; i <= num2; i++) 26 | { 27 | if (checkprime(i)) 28 | cout << i << endl; 29 | } 30 | } -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Functions Questions/problem1.exe -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void fib(int n) 5 | { 6 | int t1 = 0; 7 | int t2 = 1; 8 | 9 | for (int i = 1; i <= n; i++) 10 | { 11 | cout << t1 << " "; 12 | int nextterm = t1 + t2; 13 | t1 = t2; 14 | t2 = nextterm; 15 | } 16 | } 17 | 18 | int main() 19 | { 20 | int n; 21 | cin >> n; 22 | fib(n); 23 | } -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Functions Questions/problem2.exe -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem4.cpp: -------------------------------------------------------------------------------- 1 | //Factorial of a number 2 | 3 | #include 4 | using namespace std; 5 | 6 | int fac(int n) 7 | { 8 | int fact = 1; 9 | for (int i = n; i >= 1; i--) 10 | { 11 | fact = fact * i; 12 | } 13 | return fact; 14 | } 15 | int main() 16 | { 17 | int n; 18 | cin >> n; 19 | 20 | cout << fac(n); 21 | } -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Functions Questions/problem4.exe -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int fact(int n) 5 | { 6 | int factorial = 1; 7 | for (int i = n; i >= 1; i--) 8 | { 9 | factorial *= i; 10 | } 11 | return factorial; 12 | } 13 | 14 | int main() 15 | { 16 | int n, r; 17 | cout << "Enter n and r" << endl; 18 | cin >> n >> r; 19 | 20 | cout << (fact(n) / (fact(n - r) * fact(r))); 21 | } -------------------------------------------------------------------------------- /Apna College C++/Functions Questions/problem5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/Functions Questions/problem5.exe -------------------------------------------------------------------------------- /Apna College C++/tut1_Forloop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | 9 | int sum = 0; 10 | for (int counter = 1; counter <= n; counter++) 11 | { 12 | sum = sum + counter; 13 | } 14 | cout << sum << endl; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /Apna College C++/tut1_Forloop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/tut1_Forloop.exe -------------------------------------------------------------------------------- /Apna College C++/tut2_whileloop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | int n; 8 | cin >> n; 9 | 10 | while (n >= 0) 11 | { 12 | cout << n << endl; 13 | cin >> n; 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /Apna College C++/tut2_whileloop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/tut2_whileloop.exe -------------------------------------------------------------------------------- /Apna College C++/tut3_dowhileloop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | //prints the input number unless its negative 5 | int main() 6 | { 7 | 8 | int n; 9 | cin >> n; 10 | 11 | do 12 | { 13 | cout << n << endl; 14 | cin >> n; 15 | } while (n > 0); 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Apna College C++/tut3_dowhileloop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/tut3_dowhileloop.exe -------------------------------------------------------------------------------- /Apna College C++/tut4_break_and_continue.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int pocketmoney = 1500; 5 | 6 | int main() 7 | { 8 | for (int date = 1; date <= 30; date++) 9 | { 10 | if (date % 2 == 0) 11 | { 12 | continue; 13 | } 14 | if (pocketmoney == 0) 15 | { 16 | cout << "Your Pocket Money is Over You can't go out for rest of the month"; 17 | break; 18 | } 19 | 20 | cout << "You Can Go Out Today as today is odd date " << date << endl; 21 | pocketmoney = pocketmoney - 150; 22 | } 23 | } -------------------------------------------------------------------------------- /Apna College C++/tut4_break_and_continue.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/tut4_break_and_continue.exe -------------------------------------------------------------------------------- /Apna College C++/tut5_switchcase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | char button; 5 | int main() 6 | { 7 | cout << "Enter the button" << endl; 8 | cin >> button; 9 | 10 | switch (button) 11 | { 12 | case 'a': 13 | cout << "Hello" << endl; 14 | break; 15 | case 'b': 16 | cout << "Namaste" << endl; 17 | break; 18 | case 'c': 19 | cout << "Hola" << endl; 20 | break; 21 | 22 | default: 23 | cout << "I am learning more languages" << endl; 24 | break; 25 | } 26 | } -------------------------------------------------------------------------------- /Apna College C++/tut5_switchcase.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/tut5_switchcase.exe -------------------------------------------------------------------------------- /Apna College C++/tut6_functions.cpp: -------------------------------------------------------------------------------- 1 | //Functions 2 | 3 | #include 4 | using namespace std; 5 | 6 | //function to add two integers 7 | int add(int num1, int num2) 8 | { 9 | int sum = num1 + num2; 10 | return sum; 11 | } 12 | 13 | int main() 14 | { 15 | 16 | int n1, n2; 17 | cin >> n1 >> n2; 18 | 19 | cout << add(n1, n2) << endl; 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Apna College C++/tut6_functions.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Apna College C++/tut6_functions.exe -------------------------------------------------------------------------------- /Code With Harry/Helloworld.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | // This is the first program 5 | 6 | int main() 7 | { 8 | int hello = 24; 9 | cout << "Hello \n World" << hello; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /Code With Harry/Helloworld.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/Helloworld.exe -------------------------------------------------------------------------------- /Code With Harry/tut10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int i = 1; 7 | /* Loops in C++*/ 8 | 9 | //1. For loop 10 | 11 | //prints number upto 100 12 | for (i; i < 100; i++) 13 | { 14 | cout << i << endl; 15 | } 16 | 17 | //2. While Loop 18 | 19 | //Prints from 100 to 1 since i=100 20 | while (i > 0) 21 | { 22 | cout << i << endl; 23 | i--; 24 | } 25 | 26 | //3. Do while loop 27 | 28 | //prints from 1 to 100 29 | //difference between while and do while is do while loops runs 1 time even it doesn't satisfies the condition 30 | 31 | do 32 | { 33 | cout << i << endl; 34 | i++; 35 | } while (i < 100); 36 | 37 | return 0; 38 | } -------------------------------------------------------------------------------- /Code With Harry/tut10.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/tut10.exe -------------------------------------------------------------------------------- /Code With Harry/tut11.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | for (int i = 0; i < 4; i++) 8 | { 9 | cout << i << endl; 10 | if (i == 2) 11 | { 12 | //ends the loop 13 | break; 14 | } 15 | } 16 | 17 | for (int i = 0; i < 4; i++) 18 | { 19 | //doesn't print 2 and print all other numbers 20 | if (i == 2) 21 | { 22 | continue; 23 | } 24 | cout << i << endl; 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Code With Harry/tut11.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/tut11.exe -------------------------------------------------------------------------------- /Code With Harry/tut4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | int glo = 6; 5 | 6 | void sum() 7 | { 8 | int a; 9 | cout << glo; 10 | } 11 | 12 | int main() 13 | { 14 | // int a = 4; 15 | // int b = 5; 16 | int glo = 28; 17 | glo = 78; 18 | int a = 45, b = 54; 19 | float pie = 3.14; 20 | char c = 'c'; 21 | bool d = true; 22 | sum(); 23 | 24 | cout << "This is tutorial 4.\n Here the value of a is " << a << ".\n The value of b is " << b; 25 | sum(); 26 | cout << "\n The value of pie is " << pie; 27 | cout << "\n The value of c is " << c; 28 | cout << glo; 29 | cout << d; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /Code With Harry/tut4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/tut4.exe -------------------------------------------------------------------------------- /Code With Harry/tut5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int num1, num2; 7 | // << is called insertion operator 8 | cout << "Enter the value of num1: \n"; 9 | // >> is called exertion operator 10 | cin >> num1; 11 | 12 | cout << "Enter the value of num2: \n"; 13 | cin >> num2; 14 | 15 | cout << "The sum is " << num1 + num2; 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /Code With Harry/tut5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/tut5.exe -------------------------------------------------------------------------------- /Code With Harry/tut6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | cout << "Operators in C++ \n"; 7 | cout << "Following are the types of operators in C++ \n"; 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /Code With Harry/tut6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/tut6.exe -------------------------------------------------------------------------------- /Code With Harry/tut7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int c = 45; 6 | 7 | int main() 8 | 9 | // ***Build In Data Types*** 10 | { 11 | // int a, b, c; 12 | // cout << "Enter the value of a:" << endl; 13 | // cin >> a; 14 | // cout << "Enter the value of b:" << endl; 15 | // cin >> b; 16 | // c = a + b; 17 | // cout << "The sum is " << c << endl; 18 | // cout << "The global C is " << ::c << endl; 19 | // return 0; 20 | 21 | //***LITERALS*** 22 | // float d = 34.4f; 23 | // long double e = 34.4l; 24 | // cout << "The size of 34.4 is" << sizeof(34.4) << endl; 25 | // cout << "The size of 34.4f is" << sizeof(d) << endl; 26 | // cout << "The size of 34.4l is" << sizeof(e) << endl; 27 | 28 | //*************reference variables************** 29 | 30 | // float a = 34.4; 31 | // ; 32 | 33 | // float &b = a; 34 | // cout << "The value of a is " << a << endl; 35 | // cout << "The value of b is " << b << endl; 36 | 37 | //*************Type Casting************** 38 | 39 | int a = 45; 40 | float b = 45.46; 41 | cout << "The value of a is " << float(a) << endl; 42 | cout << "The value of a is " << (float)a << endl; 43 | cout << "The value of b is " << (int)b << endl; 44 | cout << "The value of b is " << int(b) << endl; 45 | return 0; 46 | } -------------------------------------------------------------------------------- /Code With Harry/tut7.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/tut7.exe -------------------------------------------------------------------------------- /Code With Harry/tut9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int age; 8 | cin >> age; 9 | if (age > 18) 10 | { 11 | cout << "You are eligible to vote"; 12 | } 13 | else if (age == 18) 14 | { 15 | cout << "You are eligible to vote"; 16 | } 17 | else if (age == 0) 18 | { 19 | cout << "Your are not yet born"; 20 | } 21 | else 22 | { 23 | cout << ("You are not eligible to vote") << endl; 24 | } 25 | 26 | // Switch Statement 27 | switch (age) 28 | { 29 | case 0: 30 | cout << "Your are not yet born"; 31 | break; 32 | case 18: 33 | cout << "You are eligible to vote"; 34 | break; 35 | case 19: 36 | cout << "You are eligible to vote"; 37 | break; 38 | default: 39 | cout << "Your age isn't programmed"; 40 | } 41 | return 0; 42 | } -------------------------------------------------------------------------------- /Code With Harry/tut9.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Code With Harry/tut9.exe -------------------------------------------------------------------------------- /Coding Problems/problem1.cpp: -------------------------------------------------------------------------------- 1 | // WAP To Print Numbers from 1 to 100 except those divisible by 3 2 | 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | for (int i = 1; i <= 100; i++) 9 | { 10 | if (i % 3 == 0) 11 | { 12 | continue; 13 | } 14 | 15 | cout << i << endl; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /Coding Problems/problem1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Coding Problems/problem1.exe -------------------------------------------------------------------------------- /Coding Problems/problem2.cpp: -------------------------------------------------------------------------------- 1 | //WAP to check whether the input number is prime or not 2 | 3 | #include 4 | using namespace std; 5 | 6 | int n, i; 7 | int main() 8 | { 9 | cout << "Enter The Number"; 10 | cin >> n; 11 | for (i = 2; i < n; i++) 12 | { 13 | if (n % i == 0) 14 | { 15 | cout << "Not Prime"; 16 | break; 17 | } 18 | } 19 | if (i == n) 20 | { 21 | cout << "Prime"; 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /Coding Problems/problem2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Coding Problems/problem2.exe -------------------------------------------------------------------------------- /Coding Problems/problem3.cpp: -------------------------------------------------------------------------------- 1 | //WAP to print all the prime numbers between the two input numbers 2 | 3 | #include 4 | using namespace std; 5 | 6 | int num1, num2, i, j; 7 | 8 | int main() 9 | { 10 | cout << "Enter The Numbers"; 11 | cin >> num1 >> num2; 12 | for (i = num1; i < num2; i++) 13 | { 14 | for (j = 2; j < i; j++) 15 | { 16 | if (i % j == 0) 17 | { 18 | break; 19 | } 20 | } 21 | if (j == i) 22 | { 23 | cout << j << endl; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /Coding Problems/problem3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Coding Problems/problem3.exe -------------------------------------------------------------------------------- /Coding Problems/problem4.cpp: -------------------------------------------------------------------------------- 1 | //Simple Calculator Using Switch 2 | 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | float num1, num2; 9 | cout << "Enter two Numbers" << endl; 10 | cin >> num1 >> num2; 11 | 12 | char op; 13 | cout << "Enter an Operator" << endl; 14 | cin >> op; 15 | 16 | switch (op) 17 | { 18 | case '+': 19 | cout << num1 + num2; 20 | break; 21 | 22 | case '-': 23 | cout << num1 - num2; 24 | break; 25 | 26 | case '/': 27 | cout << num1 / num2; 28 | break; 29 | 30 | case '*': 31 | cout << num1 * num2; 32 | break; 33 | 34 | default: 35 | cout << "Invalid Operator"; 36 | break; 37 | } 38 | } -------------------------------------------------------------------------------- /Coding Problems/problem4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Coding Problems/problem4.exe -------------------------------------------------------------------------------- /Coding Problems/problem5.cpp: -------------------------------------------------------------------------------- 1 | //WAP TO CHECK WHETHER THE INPUT CHARACTER IS VOWEL OR NOT 2 | 3 | #include 4 | using namespace std; 5 | 6 | int main() 7 | { 8 | char c; 9 | cout << "Enter a character" << endl; 10 | cin >> c; 11 | 12 | switch (c) 13 | { 14 | case 'a': 15 | cout << "It Is Vowel"; 16 | break; 17 | case 'e': 18 | cout << "It Is Vowel"; 19 | break; 20 | case 'i': 21 | cout << "It Is Vowel"; 22 | break; 23 | case 'o': 24 | cout << "It Is Vowel"; 25 | break; 26 | case 'u': 27 | cout << "It Is Vowel"; 28 | break; 29 | 30 | default: 31 | cout << "It is Consonent"; 32 | break; 33 | } 34 | } -------------------------------------------------------------------------------- /Coding Problems/problem5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Coding Problems/problem5.exe -------------------------------------------------------------------------------- /Coding Problems/problem6.cpp: -------------------------------------------------------------------------------- 1 | //Factorial of a number 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | 8 | int n, factorial = 1; 9 | cin >> n; 10 | 11 | for (int i = n; i >= 1; i--) 12 | { 13 | factorial = factorial * i; 14 | } 15 | cout << factorial; 16 | } -------------------------------------------------------------------------------- /Coding Problems/problem6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Coding Problems/problem6.exe -------------------------------------------------------------------------------- /Coding Problems/problem7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | } -------------------------------------------------------------------------------- /Coding Problems/problem8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | for (int i = (2 * n - 1); i >= 1; i--) 9 | { 10 | for (int j = 1; j <= (2 * n - 1); j++) 11 | { 12 | if (i == 1 || i == (2 * n - 1) || j == 1 || j == (2 * n - 1)) 13 | { 14 | cout << n; 15 | } 16 | else if (i == 2 || i == (2 * n - 2) || j == 2 || j == (2 * n - 2)) 17 | { 18 | cout << (n - 1); 19 | } 20 | else if (i == 3 || i == (2 * n - 3) || j == 3 || j == (2 * n - 3)) 21 | { 22 | cout << (n - 2); 23 | } 24 | else 25 | { 26 | cout << n - 3; 27 | } 28 | } 29 | cout << endl; 30 | } 31 | } -------------------------------------------------------------------------------- /Coding Problems/problem8.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/unikdahal/Learning-cpp/410e03ef8c6442bd560330004a558783056e7a5e/Coding Problems/problem8.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Learning-C++ 2 | Codes While Learning C++ From Code With Harry And Apna College 3 | --------------------------------------------------------------------------------