├── .vscode ├── c_cpp_properties.json ├── settings.json └── tasks.json ├── 01_variable_constant_keyword ├── 01_area_of_rectangle.c ├── 01_area_of_rectangle.exe ├── 02_area_of_circle.c ├── 02_area_of_circle.exe ├── 03 celcius to farenheit.c ├── 03 celcius to farenheit.exe ├── 03 celcius to farenheit.o ├── 04 simple interest.c ├── Variables.c ├── a.exe ├── hello.c ├── hello.exe ├── take input by scanf.c └── variables_constant_keyword.c ├── 02_operators ├── 01_Divisibility test.c ├── 01_Divisibility test.exe ├── 01_Divisibility test.o ├── 04_step evaluation.c ├── 04_step evaluation.exe ├── 04_step evaluation.o └── Operator precedence.c ├── 03_conditional_statements ├── 01 output program.c ├── 02 student mark.c ├── 03 income tax.c ├── 04 leap year.c ├── 05 character chek.c ├── 06 find greatest number.c ├── 06 find greatest number.exe ├── 06 find greatest number.o ├── check even or odd.c ├── else if.c ├── grade of student marks.c ├── logical operator.c └── switch case.c ├── 04_loop_control_instructions ├── 01 multiplication table.c ├── 01 multiplication table.exe ├── 01 multiplication table.o ├── 02 reverse multiplication table.c ├── 02 reverse multiplication table.exe ├── 02 reverse multiplication table.o ├── 05 sum natural numbers.c ├── 05 sum natural numbers.exe ├── 05 sum natural numbers.o ├── 08 factorial number.c ├── 08 factorial number.exe ├── 08 factorial number.o ├── 10 checking prime numbers.c ├── 10 checking prime numbers.exe ├── 10 checking prime numbers.o ├── break loop.c ├── compound assignment.c ├── quiz 02_natural number.c ├── quiz 03_for loop number.c └── quiz 1_natural number print.c ├── 05_function ├── 01 average of number.c ├── 01 average of number.exe ├── 01 average of number.o ├── 02 celcius to fahrenheit.c ├── 02 celcius to fahrenheit.exe ├── 02 celcius to fahrenheit.o ├── 04 fibonacci series.c ├── 04 fibonacci series.exe ├── 04 fibonacci series.o ├── 06 calculate first n natural numbers.c ├── 06 calculate first n natural numbers.exe ├── 06 calculate first n natural numbers.o ├── 07 print pattern.c ├── 07 print pattern.exe ├── 07 print pattern.o ├── calculate force.c ├── calculate force.exe ├── calculate force.o ├── parameter & argument.c ├── parameter & argument.exe ├── parameter & argument.o ├── quiz 01.c ├── quiz 01.exe └── quiz 01.o ├── 06 pointers ├── 01 use address get variable.c ├── 02 address same or not.c ├── 04 sum & average.c ├── 04 sum & average.exe ├── 04 sum & average.o ├── 05 ptr to ptr.c ├── 05 ptr to ptr.exe ├── 05 ptr to ptr.o └── value & address.c ├── 07 arrays ├── 01 arithmatic array.c ├── 02 multiplication table.c ├── 03 reverse array by function.c ├── 04 multiple table.c ├── 05 3d array.c ├── array in function.c ├── array input.c ├── input using loops.c └── multi dimensional array.c ├── 08 strings ├── gets & puts.c ├── gets & puts.exe ├── gets & puts.o ├── input string.c ├── str cat.c ├── str cmp.c ├── str cmp.exe ├── str cmp.o ├── string in easy way.c ├── string with loop.c ├── strlen.c └── strspy.c ├── 09 structure ├── 01 two dimensional vector.c ├── 02 sum in function.c ├── 03 date & time comparision.c ├── array in struct.c ├── function in struct.c ├── input struct.c ├── intro struct.c ├── other way array in struct.c ├── pointer to struct.c └── typedef in struct.c ├── C project ├── ATM BANKING SYSTEM │ ├── ATM_BANKING_IN_C.c │ ├── ATM_BANKING_IN_C.exe │ └── ATM_BANKING_IN_C.o ├── Calender App in C │ ├── Calender_App_C_Programming.c │ ├── Calender_App_C_Programming.exe │ └── Calender_App_C_Programming.o ├── Phone Book system in C │ ├── contact.txt │ ├── simplephone.c │ ├── simplephone.exe │ └── simplephone.o └── Stop Watch in C │ ├── Stop_Watch_by_C_language.c │ ├── Stop_Watch_by_C_language.exe │ └── Stop_Watch_by_C_language.o ├── README.md ├── data_structure_algorithm ├── binary_search.cpp ├── binary_search.exe ├── linear_search.cpp ├── linear_search.exe ├── selection_sort.cpp ├── selection_sort.exe ├── space_complexity.cpp ├── space_complexity.exe ├── time_complexity.cpp └── time_complexity.exe ├── file Input & Output ├── file open.c ├── file open.exe ├── file open.o └── simple.txt └── problem_solving ├── ps01.c ├── ps01.exe ├── ps02.cpp ├── ps02.exe ├── ps03_odd_even.cpp ├── ps03_odd_even.exe ├── ps04_leap_year.cpp ├── ps04_leap_year.exe ├── ps05_simple_loop.cpp ├── ps05_simple_loop.exe ├── ps06_piramid_pattern.cpp ├── ps06_piramid_pattern.exe ├── ps07_array_string.cpp ├── ps07_array_string.exe ├── ps08_string_problem.cpp ├── ps08_string_problem.exe ├── string_library_function.cpp └── string_library_function.exe /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Win32", 5 | "includePath": [ 6 | "${workspaceFolder}/**" 7 | ], 8 | "defines": [ 9 | "_DEBUG", 10 | "UNICODE", 11 | "_UNICODE" 12 | ], 13 | "cStandard": "c17", 14 | "cppStandard": "c++17", 15 | "intelliSenseMode": "windows-msvc-x64" 16 | } 17 | ], 18 | "version": 4 19 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "C_Cpp.errorSquiggles": "Disabled", 3 | "files.associations": { 4 | "iostream": "cpp", 5 | "iosfwd": "cpp" 6 | } 7 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": [ 3 | { 4 | "type": "cppbuild", 5 | "label": "C/C++: gcc.exe build active file", 6 | "command": "C:\\Program Files\\MinGW\\bin\\gcc.exe", 7 | "args": [ 8 | "-fdiagnostics-color=always", 9 | "-g", 10 | "${file}", 11 | "-o", 12 | "${fileDirname}\\${fileBasenameNoExtension}.exe" 13 | ], 14 | "options": { 15 | "cwd": "${fileDirname}" 16 | }, 17 | "problemMatcher": [ 18 | "$gcc" 19 | ], 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | }, 24 | "detail": "Task generated by Debugger." 25 | } 26 | ], 27 | "version": "2.0.0" 28 | } -------------------------------------------------------------------------------- /01_variable_constant_keyword/01_area_of_rectangle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //Formula: area = length * Breadth 4 | 5 | int main() 6 | { 7 | int length, breadth, area; 8 | 9 | area = length * breadth; 10 | 11 | printf("Enter the number of length\n"); 12 | scanf("%d", &length); 13 | 14 | printf("Enter the number of breadth\n"); 15 | scanf("%d", &breadth); 16 | 17 | printf("the area of rectangle is %d", length*breadth); 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /01_variable_constant_keyword/01_area_of_rectangle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/01_variable_constant_keyword/01_area_of_rectangle.exe -------------------------------------------------------------------------------- /01_variable_constant_keyword/02_area_of_circle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | // Formula: Area = pi * r * r 5 | 6 | //volume of a cylinder Formula: V = pi * r * r *h 7 | 8 | int main() 9 | { 10 | int radius, height; 11 | float pi; 12 | pi = 3.1416; 13 | 14 | printf("Enter the value of radius\n"); 15 | scanf("%d", &radius); 16 | 17 | printf("the area of circle is %f\n\n", pi*radius*radius); 18 | 19 | printf("What is the height?\n"); 20 | scanf("%d", &height); 21 | 22 | printf("the volume of a cylinder is %f", pi * radius * radius * height); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /01_variable_constant_keyword/02_area_of_circle.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/01_variable_constant_keyword/02_area_of_circle.exe -------------------------------------------------------------------------------- /01_variable_constant_keyword/03 celcius to farenheit.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/01_variable_constant_keyword/03 celcius to farenheit.c -------------------------------------------------------------------------------- /01_variable_constant_keyword/03 celcius to farenheit.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/01_variable_constant_keyword/03 celcius to farenheit.exe -------------------------------------------------------------------------------- /01_variable_constant_keyword/03 celcius to farenheit.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/01_variable_constant_keyword/03 celcius to farenheit.o -------------------------------------------------------------------------------- /01_variable_constant_keyword/04 simple interest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int principal, year; 6 | float rate, simpleInterest; 7 | 8 | printf("Enter the number of Principal Amount\n"); 9 | scanf("%d", &principal); 10 | 11 | printf("Enter the number of Year\n"); 12 | scanf("%d", &year); 13 | 14 | printf("Enter the amount of Rate per Year\n"); 15 | scanf("%f", &rate); 16 | 17 | simpleInterest = (principal * year * rate)/100; 18 | 19 | printf("The value of Simple Interest is %f", simpleInterest); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /01_variable_constant_keyword/Variables.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a = 4; 6 | float b = 2.4; 7 | char c = 'u'; 8 | int d = a + 10; //14 9 | int e = d / 2; //7 10 | int f = e - 2; //5 11 | int g = f * 5; //25 12 | 13 | printf("this is integer file a: %d\n", a); //int used for integer variables 14 | printf("this is float file b: %f\n", b); //float used for real variables 15 | printf("this is character file c: %c\n\n", c); //char used for character variables 16 | 17 | printf("the value of d is %d\n", d); 18 | printf("the value of e is %d\n", e); 19 | printf("the value of f is %d\n", f); 20 | printf("the value of g is %d\n\n", g); 21 | 22 | printf("the addition of a and g is %d\n", a+g); 23 | printf("the substraction of d and e is %d\n", d-e); 24 | printf("the multiplication of e and f is %d\n", e*f); 25 | printf("the division of g and f is %d\n", g/f); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /01_variable_constant_keyword/a.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/01_variable_constant_keyword/a.exe -------------------------------------------------------------------------------- /01_variable_constant_keyword/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | printf("Hello I am restarting C"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /01_variable_constant_keyword/hello.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/01_variable_constant_keyword/hello.exe -------------------------------------------------------------------------------- /01_variable_constant_keyword/take input by scanf.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int a, b, c; 6 | 7 | printf("Enter the value of a\n"); 8 | scanf("%d", &a); 9 | 10 | printf("Enter the value of b\n"); 11 | scanf("%d", &b); 12 | 13 | printf("Enter the value of c\n"); 14 | scanf("%d", &c); 15 | 16 | printf("the value of a is %d\n", a); 17 | printf("the value of b is %d\n", b); 18 | printf("the value of c is %d\n\n", c); 19 | 20 | printf("the multiplying of a and b is %d\n", a*b); 21 | printf("the add of b and c is %d\n", b + c); 22 | printf("the substraction of c and a is %d\n", c - a); 23 | printf("the division of c and a %d\n", c / a); 24 | 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /01_variable_constant_keyword/variables_constant_keyword.c: -------------------------------------------------------------------------------- 1 | # include 2 | 3 | int main(){ 4 | 5 | int tom, Tom, car; //tom, Tom, car are variables. 6 | 7 | tom = 3; 8 | Tom = 2.3; // C programing is case sensitive, tom and Tom are not same. 9 | car = 'c'; //3, 2.3 and 'c' are constants 10 | 11 | 12 | printf("this is variables\n"); 13 | printf("this is constant\n"); 14 | printf("this is keyword"); 15 | //what is written on " "code in printf is called String. 16 | 17 | return 0; //int, return are keywords. In C there are 32 keywords. 18 | } 19 | -------------------------------------------------------------------------------- /02_operators/01_Divisibility test.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | int main() 5 | { 6 | int num; 7 | 8 | printf("Enter your desire number\n"); 9 | scanf("%d", &num); 10 | 11 | printf("the divisibility test is %d\n", num%97); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /02_operators/01_Divisibility test.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/02_operators/01_Divisibility test.exe -------------------------------------------------------------------------------- /02_operators/01_Divisibility test.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/02_operators/01_Divisibility test.o -------------------------------------------------------------------------------- /02_operators/04_step evaluation.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int x, y, z, r; 6 | 7 | x =2; 8 | y =3; 9 | z =3; 10 | r =30; 11 | 12 | printf("the evaluation is %d", 3 * x / y - z + r); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /02_operators/04_step evaluation.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/02_operators/04_step evaluation.exe -------------------------------------------------------------------------------- /02_operators/04_step evaluation.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/02_operators/04_step evaluation.o -------------------------------------------------------------------------------- /02_operators/Operator precedence.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | float x, y, z; 6 | x = 2; 7 | y = 3; 8 | z = 4; 9 | 10 | // Priority Operators 11 | // 1st * / % 12 | // 2nd + - 13 | // 3rd = 14 | 15 | // *, / Follows left to right associativity in C programming. 16 | 17 | printf("the value of x * y / z is %f\n", x*y/z ); 18 | printf("the value of x / y * z is %f\n\n", x/y*z); 19 | printf("the value of 3*x - 8*y is %f\n", 3*x - 8*y); 20 | printf("the value of 3*(x - 8*y) is %f\n\n", 3*(x - 8*y)); 21 | printf("the value of 8*y / 3*x is %f\n", 8*y / 3*x); 22 | // 24/3*2 ->multiply by 8*y gives 24 23 | // 8*2 ->divided by 24/3 gives 8 24 | // 16 ->again multiply by 8*2 gives answer 16. 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /03_conditional_statements/01 output program.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int a =10; 7 | if(a =11) 8 | { 9 | printf("I am 11"); 10 | } 11 | else 12 | { 13 | printf("I am not 11"); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /03_conditional_statements/02 student mark.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | float physics, chemistry, math; 6 | float total; 7 | 8 | 9 | printf("Enter physics mark: "); 10 | scanf("%f", &physics); 11 | printf("Enter chemistry mark: "); 12 | scanf("%f", &chemistry); 13 | printf("Enter math mark: "); 14 | scanf("%f", &math); 15 | 16 | total = physics + chemistry + math/3; 17 | 18 | if(total<=40 || physics<=33 || chemistry<=33 || math<=33 ) 19 | { 20 | printf("you got %f, you are fail", total); 21 | } 22 | else 23 | { 24 | printf("you are pass"); 25 | } 26 | 27 | 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /03_conditional_statements/03 income tax.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int income; 7 | float tax; 8 | 9 | printf("Enter you Monthly Income\n"); 10 | scanf("%d", &income); 11 | 12 | if(income>=250000 && income<=500000) 13 | { 14 | tax = tax + 0.05 * (income - 250000); 15 | } 16 | if(income>500000 && income<=1000000) 17 | { 18 | tax = tax + 0.20 * (income - 500000); 19 | } 20 | if(income>1000000) 21 | { 22 | tax = tax + 0.30 * (income - 1000000); 23 | } 24 | 25 | 26 | 27 | printf("you have to pay %f monthly tax", tax); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /03_conditional_statements/04 leap year.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int year; 6 | 7 | printf("Enter the year\n"); 8 | scanf("%d", &year); 9 | 10 | if(year%4==0){ 11 | printf("%d is the leap year", year); 12 | } 13 | else{ 14 | printf("%d is not the leap year", year); 15 | } 16 | 17 | 18 | 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /03_conditional_statements/05 character chek.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | char word; 6 | 7 | printf("Enter your character\n"); 8 | scanf("%c", &word); 9 | 10 | if(word>=65 && word<=90){ 11 | printf("this is Uppercase character"); 12 | } 13 | else{ 14 | printf("this is Lowercase character"); 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /03_conditional_statements/06 find greatest number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int one, two, three, four; 7 | 8 | printf("Enter your first number: "); 9 | scanf("%d", &one); 10 | printf("Enter your second number: "); 11 | scanf("%d", &two); 12 | printf("Enter your third number: "); 13 | scanf("%d", &three); 14 | printf("Enter your fourth number: "); 15 | scanf("%d", &four); 16 | printf("\n"); 17 | if(one>two) 18 | { 19 | printf("the first number %d is greatest number\n", one); 20 | } 21 | if(two>one && two>three) 22 | { 23 | printf("the second number %d is greatest number\n", two); 24 | } 25 | if(three>one && three>two && three>four) 26 | { 27 | printf("the third number %d is greatest number\n", three); 28 | } 29 | if(four>one && four>two && four>three) 30 | { 31 | printf("the fourth number %d is the greatest number\n", four); 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /03_conditional_statements/06 find greatest number.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/03_conditional_statements/06 find greatest number.exe -------------------------------------------------------------------------------- /03_conditional_statements/06 find greatest number.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/03_conditional_statements/06 find greatest number.o -------------------------------------------------------------------------------- /03_conditional_statements/check even or odd.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int num; 6 | 7 | printf("Enter your number: "); 8 | scanf("%d",&num); 9 | 10 | if(num%2==0){ 11 | printf("the number %d is even", num); 12 | } 13 | 14 | else{ 15 | printf("the number %d is odd", num); 16 | } 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /03_conditional_statements/else if.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int num; 6 | 7 | printf("Enter your number: "); 8 | scanf("%d", &num); 9 | 10 | if(num<=12){ 11 | printf("now you are a Kid\n"); 12 | printf("you can not drive"); 13 | } 14 | else if(num>=12 && num<=17){ 15 | printf("now you are a Teen\n"); 16 | printf("keep learning driving"); 17 | } 18 | else if(num>=18 && num<=30){ 19 | printf("now you are an adult\n"); 20 | printf("you can drive"); 21 | } 22 | else{ 23 | printf("you are older than 30\n"); 24 | printf("you must know drive"); 25 | } 26 | 27 | 28 | 29 | 30 | return 0; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /03_conditional_statements/grade of student marks.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int mark; 6 | 7 | printf("Enter the Student Mark: "); 8 | scanf("%d", &mark); 9 | 10 | if(mark>=90 && mark<=100) 11 | { 12 | printf("you got A+"); 13 | } 14 | if(mark>=80 && mark<90) 15 | { 16 | printf("you got A"); 17 | } 18 | if(mark>=70 && mark<80) 19 | { 20 | printf("you got B"); 21 | } 22 | if(mark>=60 && mark<70) 23 | { 24 | printf("you got C"); 25 | } 26 | if(mark>=50 && mark<60) 27 | { 28 | printf("you got D"); 29 | } 30 | if(mark<50) 31 | { 32 | printf("you are fail"); 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /03_conditional_statements/logical operator.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int age; 6 | char vipPass; 7 | 8 | 9 | printf("Enter your age\n"); 10 | scanf("%d", &age); 11 | 12 | if(age<=70 && age>=18) 13 | { 14 | printf("you can drive\n"); 15 | } 16 | 17 | else 18 | { 19 | printf("you cannot drive\n"); 20 | } 21 | 22 | 23 | return 0; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /03_conditional_statements/switch case.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | 5 | int mark; 6 | 7 | printf("Enter your rating number from (1-5)\n"); 8 | scanf("%d", &mark); 9 | 10 | switch(mark){ 11 | case c1= 90-100: 12 | printf("your rating is A+"); 13 | break; 14 | case 80-89: 15 | printf("your rating is A"); 16 | break; 17 | case 3: 18 | printf("your rating is 3"); 19 | break; 20 | case 4: 21 | printf("your rating is 4"); 22 | break; 23 | case 5: 24 | printf("your rating is 5"); 25 | break; 26 | default: 27 | printf("Invalid rating"); 28 | break; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /04_loop_control_instructions/01 multiplication table.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int m, s, e; //m=multiplication; s=start; e=end; 6 | printf("Enter the Multiplication number: "); 7 | scanf("%d", &m); 8 | printf("Your Multiply number starts from: "); 9 | scanf("%d", &s); 10 | printf("Your Multiply number Ends at: "); 11 | scanf("%d", &e); 12 | printf("\n"); 13 | 14 | for(s; s<=e; s++) 15 | { 16 | printf("the Multiplication of %d * %d is %d\n",m, s, m*s); 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /04_loop_control_instructions/01 multiplication table.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/01 multiplication table.exe -------------------------------------------------------------------------------- /04_loop_control_instructions/01 multiplication table.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/01 multiplication table.o -------------------------------------------------------------------------------- /04_loop_control_instructions/02 reverse multiplication table.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int m, s, e; 6 | 7 | printf("Enter the Multiplication number: "); 8 | scanf("%d", &m); 9 | printf("The Reverse Multiply stars from: "); 10 | scanf("%d", &s); 11 | printf("The Multiply Ends at: "); 12 | scanf("%d", &e); 13 | printf("\n"); 14 | 15 | for(s; s>=e; s--) 16 | { 17 | printf("the reverse multiplication of %d * %d is %d\n", m, s, m*s ); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /04_loop_control_instructions/02 reverse multiplication table.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/02 reverse multiplication table.exe -------------------------------------------------------------------------------- /04_loop_control_instructions/02 reverse multiplication table.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/02 reverse multiplication table.o -------------------------------------------------------------------------------- /04_loop_control_instructions/05 sum natural numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n,i, sum; 6 | 7 | printf("Enter the number you want to start sum: "); 8 | scanf("%d", &n); 9 | printf("How much do you want to run sum: "); 10 | scanf("%d", &i); 11 | printf("\n"); 12 | 13 | while(n<=i) 14 | { 15 | sum+=n; 16 | n++; 17 | } 18 | 19 | printf("the number you entered total sum is %d\n",sum); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /04_loop_control_instructions/05 sum natural numbers.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/05 sum natural numbers.exe -------------------------------------------------------------------------------- /04_loop_control_instructions/05 sum natural numbers.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/05 sum natural numbers.o -------------------------------------------------------------------------------- /04_loop_control_instructions/08 factorial number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, i, fac; 6 | fac = 1; 7 | 8 | printf("Enter the Factorial number: "); 9 | scanf("%d", &i); 10 | printf("\n"); 11 | 12 | for(n=1; n<=i; n++) 13 | { 14 | fac*=n; // factorial = factorial * n 15 | } 16 | printf("the value of %d factorial number is %d\n",i, fac); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /04_loop_control_instructions/08 factorial number.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/08 factorial number.exe -------------------------------------------------------------------------------- /04_loop_control_instructions/08 factorial number.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/04_loop_control_instructions/08 factorial number.o -------------------------------------------------------------------------------- /04_loop_control_instructions/10 checking prime numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /*List of Prime Numbers Up to 100. 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 4 | 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97*/ 5 | 6 | int main() 7 | { 8 | int num, i, prime; 9 | prime = 1; 10 | 11 | printf("Enter the Number: "); 12 | scanf("%d", &num); 13 | 14 | for(i=2; i 2 | 3 | int main() 4 | { 5 | int i; 6 | 7 | printf("Enter the value of i: "); 8 | scanf("%d", &i); 9 | 10 | for(i; i<15; i++) 11 | { 12 | printf("%d\n", i); 13 | if(i==7) 14 | { 15 | break; 16 | } 17 | } 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /04_loop_control_instructions/compound assignment.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int num; 7 | 8 | printf("Enter the value of Number\n"); 9 | scanf("%d", &num); 10 | 11 | num+=1; 12 | printf("the += operator value is %d\n", num); 13 | 14 | num-=3; 15 | printf("the -= operator value is %d\n", num); 16 | 17 | num*=2; 18 | printf("the *= operator value is %d\n", num); 19 | 20 | num/=2; 21 | printf("the /= operator value is %d\n", num); 22 | 23 | num%=2; 24 | printf("the %= operator value is %d", num); 25 | 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /04_loop_control_instructions/quiz 02_natural number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, i; 6 | 7 | printf("Enter your natural number: "); 8 | scanf("%d", &n); 9 | printf("Enter your increment number: "); 10 | scanf("%d", &i); 11 | 12 | do{ 13 | 14 | printf("%d\n", n); 15 | n++; 16 | }while(n<=i); 17 | 18 | printf("Enter your natural number: "); 19 | scanf("%d", &n); 20 | printf("Enter your decrement number: "); 21 | scanf("%d", &i); 22 | 23 | do{ 24 | 25 | printf("%d\n", n); 26 | n--; 27 | }while(n>=i); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /04_loop_control_instructions/quiz 03_for loop number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i, d; 6 | 7 | //for(initialize; test; increment/decrement) 8 | 9 | //initialize = setting a loop counter to an initial value ; 10 | //Test = checking a condition; 11 | //Increment = updating the loop counter; 12 | 13 | //incrementing the numbers 14 | printf("Enter the number for increment: "); 15 | scanf("%d", &i); 16 | 17 | for(i; i<10; i++) 18 | { 19 | printf("%d\n", i); 20 | } 21 | 22 | 23 | //decrementing the numbers 24 | printf("Enter the number for decrement: "); 25 | scanf("%d", &d); 26 | 27 | for(d; d>5; d--) 28 | { 29 | printf("%d\n", d); 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /04_loop_control_instructions/quiz 1_natural number print.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, i; 6 | printf("Enter value of n: "); 7 | scanf("%d", &n); 8 | 9 | while(n>=10 && n<=20) 10 | { 11 | printf("%d\n", n); 12 | n++; // n++ = Increment Operator 13 | } 14 | 15 | printf("\n"); 16 | 17 | printf("Enter the value of i: "); 18 | scanf("%d", &i); 19 | 20 | while(i>=20 && i<=30) 21 | { 22 | printf("%d\n", i); 23 | i--; // i-- = Decrement Operator 24 | } 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /05_function/01 average of number.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float average(); 4 | 5 | int main() 6 | { 7 | float result; 8 | 9 | result = average()/3; 10 | 11 | printf("the average of three number is %f", result); 12 | 13 | return 0; 14 | } 15 | 16 | float average(int one, int two, int three, int sum) 17 | { 18 | printf("Enter your first number:\n"); 19 | scanf("%d", &one); 20 | printf("Enter your second number:\n"); 21 | scanf("%d", &two); 22 | printf("Enter your third number:\n"); 23 | scanf("%d", &three); 24 | 25 | sum = one + two + three; 26 | 27 | return sum; 28 | } 29 | -------------------------------------------------------------------------------- /05_function/01 average of number.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/01 average of number.exe -------------------------------------------------------------------------------- /05_function/01 average of number.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/01 average of number.o -------------------------------------------------------------------------------- /05_function/02 celcius to fahrenheit.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float faren(float faren); // Function Declareation 4 | 5 | int main() 6 | { 7 | int c; 8 | 9 | printf("Enter the number of celsius: "); 10 | scanf("%d", &c); 11 | printf("\n"); 12 | 13 | printf("the result of fahrenheit is %.2f", faren(c)); // Function Call 14 | printf("\n"); 15 | 16 | return 0; 17 | } 18 | float faren(float cel) // Function Definition 19 | { 20 | float result; 21 | result = (cel * 1.8) + 32; 22 | 23 | return result; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /05_function/02 celcius to fahrenheit.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/02 celcius to fahrenheit.exe -------------------------------------------------------------------------------- /05_function/02 celcius to fahrenheit.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/02 celcius to fahrenheit.o -------------------------------------------------------------------------------- /05_function/04 fibonacci series.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int fib(int x); 4 | 5 | int main() 6 | { 7 | int n; 8 | 9 | printf("Enter the number you want to see Fibonacci series: "); 10 | scanf("%d", &n); 11 | 12 | for(n; n>=0; n--) 13 | { 14 | 15 | printf("the Fibonacci number %d is %d\n", n, fib(n)); 16 | } 17 | 18 | 19 | return 0; 20 | } 21 | 22 | int fib(int x) 23 | { 24 | if(x==0) 25 | { 26 | return 0; 27 | } 28 | if(x==1) 29 | { 30 | return 1; 31 | } 32 | 33 | return fib(x-1) + fib(x-2); 34 | } 35 | -------------------------------------------------------------------------------- /05_function/04 fibonacci series.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/04 fibonacci series.exe -------------------------------------------------------------------------------- /05_function/04 fibonacci series.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/04 fibonacci series.o -------------------------------------------------------------------------------- /05_function/06 calculate first n natural numbers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int nat(int x); 4 | 5 | int main() 6 | { 7 | int n; 8 | 9 | printf("Enter the number you want to do sum: "); 10 | scanf("%d", &n); 11 | 12 | printf("the sum is %d", nat(n)); 13 | 14 | return 0; 15 | } 16 | 17 | int nat(int x) 18 | { 19 | return x+=1; 20 | } 21 | -------------------------------------------------------------------------------- /05_function/06 calculate first n natural numbers.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/06 calculate first n natural numbers.exe -------------------------------------------------------------------------------- /05_function/06 calculate first n natural numbers.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/06 calculate first n natural numbers.o -------------------------------------------------------------------------------- /05_function/07 print pattern.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void pattern(int n); 4 | 5 | int main() 6 | { 7 | int s; 8 | 9 | printf("Enter the number to see star: "); 10 | scanf("%d", &s); 11 | 12 | pattern(s); 13 | return 0; 14 | } 15 | 16 | void pattern(int n) 17 | { 18 | int i; 19 | if(n==1) 20 | { 21 | printf("*\n"); 22 | return ; 23 | } 24 | 25 | pattern(n-1); 26 | for(i=0; i<(2*n-1); i++) 27 | { 28 | printf("*"); 29 | } 30 | printf("\n"); 31 | } 32 | -------------------------------------------------------------------------------- /05_function/07 print pattern.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/07 print pattern.exe -------------------------------------------------------------------------------- /05_function/07 print pattern.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/07 print pattern.o -------------------------------------------------------------------------------- /05_function/calculate force.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | float force(float mass); 4 | 5 | int main() 6 | { 7 | int m; 8 | 9 | printf("Enter the number of mass: "); 10 | scanf("%d", &m); 11 | 12 | printf("the result of force is %.2f", force(m)); 13 | 14 | return 0; 15 | } 16 | float force(float mass) 17 | { 18 | float result; 19 | 20 | result = mass * 9.8; 21 | 22 | return result; 23 | } 24 | -------------------------------------------------------------------------------- /05_function/calculate force.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/calculate force.exe -------------------------------------------------------------------------------- /05_function/calculate force.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/calculate force.o -------------------------------------------------------------------------------- /05_function/parameter & argument.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sum(int a, int b); // Function Decalaration 4 | 5 | int main() 6 | { 7 | int d; 8 | 9 | sum(10, 5); // 10, 5 are the actual value & its called Arguments 10 | 11 | d = sum(10, 5); 12 | 13 | printf("the value is sum is %d", d); 14 | 15 | 16 | return 0; 17 | } 18 | 19 | int sum(int a, int b) // int a, int b are placeholder for function & Parameters 20 | { 21 | int result; 22 | 23 | result = a + b; 24 | 25 | return result; // this function returns integer as an output to main function 26 | } 27 | -------------------------------------------------------------------------------- /05_function/parameter & argument.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/parameter & argument.exe -------------------------------------------------------------------------------- /05_function/parameter & argument.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/parameter & argument.o -------------------------------------------------------------------------------- /05_function/quiz 01.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void morning(); 4 | void afternoon(); 5 | void night(); 6 | 7 | int main() 8 | { 9 | int a; 10 | 11 | printf("the function initialization starts from here\n"); 12 | 13 | morning(); 14 | afternoon(); 15 | night(); 16 | 17 | printf("the function finished here"); 18 | 19 | return 0; 20 | } 21 | 22 | void morning() 23 | { 24 | printf("this is good morning\n"); 25 | } 26 | void afternoon() 27 | { 28 | printf("this is good afternoon\n"); 29 | } 30 | void night() 31 | { 32 | printf("this is good night\n"); 33 | } 34 | -------------------------------------------------------------------------------- /05_function/quiz 01.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/quiz 01.exe -------------------------------------------------------------------------------- /05_function/quiz 01.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/05_function/quiz 01.o -------------------------------------------------------------------------------- /06 pointers/01 use address get variable.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int p; 6 | p = 30; 7 | int *ptr = &p; 8 | 9 | printf("the address of variable is %u\n", &p); 10 | 11 | printf("the value of this variable is %d", *ptr); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /06 pointers/02 address same or not.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void func(int a) 4 | { 5 | 6 | printf("the address of ab is %u\n", &a); 7 | } 8 | 9 | int main() 10 | { 11 | int i=4; 12 | 13 | printf("the value of i is %d\n", i); 14 | 15 | func(i); 16 | printf("the address of a is %u", &i); 17 | } 18 | -------------------------------------------------------------------------------- /06 pointers/04 sum & average.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void sumavg(int a, int b, int *sum, float *avg); 4 | 5 | 6 | int main() 7 | { 8 | int x, y, sum; 9 | float avg; 10 | 11 | printf("Enter the value of a: "); 12 | scanf("%d",&x); 13 | printf("Enter the value of y: "); 14 | scanf("%d",&y); 15 | printf("\n"); 16 | 17 | sumavg(x, y, &sum, &avg); 18 | printf("the sum of a & b is %d\n", sum); 19 | printf("the average of a & b is %f\n", avg); 20 | printf("\n"); 21 | 22 | return 0; 23 | } 24 | void sumavg(int a, int b, int *sum, float *avg) 25 | { 26 | *sum = a + b; 27 | *avg = (float)*sum/2; 28 | } 29 | -------------------------------------------------------------------------------- /06 pointers/04 sum & average.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/06 pointers/04 sum & average.exe -------------------------------------------------------------------------------- /06 pointers/04 sum & average.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/06 pointers/04 sum & average.o -------------------------------------------------------------------------------- /06 pointers/05 ptr to ptr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i; 6 | 7 | printf("Enter the value of i: "); 8 | scanf("%d", &i); 9 | printf("\n"); 10 | 11 | int *ptr = &i; 12 | int **ptr_ptr = &ptr; 13 | 14 | printf("the value of ptr to ptr is %d\n", **ptr_ptr); 15 | printf("the value of ptr is %d\n", *ptr); 16 | printf("\n"); 17 | printf("the address of ptr to ptr is %u\n", &ptr_ptr); 18 | printf("the address of ptr is %u\n", &ptr); 19 | printf("\n"); 20 | 21 | 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /06 pointers/05 ptr to ptr.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/06 pointers/05 ptr to ptr.exe -------------------------------------------------------------------------------- /06 pointers/05 ptr to ptr.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/06 pointers/05 ptr to ptr.o -------------------------------------------------------------------------------- /06 pointers/value & address.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i; 6 | i = 30; 7 | int *j = &i; 8 | 9 | printf("the value of i is %d\n", i); //declares the integer value of i 10 | 11 | printf("the value of i is %d\n", *j); //*j stores the i address, so it gives integer i value 12 | 13 | printf("the address of i is %u\n", &i); //%u uses for &i, it gives the address of &i 14 | //&i is used for memory address of i. 15 | 16 | printf("the address of i is %u\n", j); //*j is declared as pointer, and it stores the value of i. 17 | //only j is called by %u is the memory address of only i. 18 | 19 | printf("the address of j is %u\n", &j); //&j is give the memory address of just j. 20 | 21 | printf("the value of i is %d\n", i); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /07 arrays/01 arithmatic array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int arr[10]; 6 | int *ptr = &arr[0]; 7 | ptr = ptr + 2; 8 | 9 | if(ptr == &arr[2]) 10 | { 11 | printf("the points to the same location"); 12 | } 13 | else 14 | { 15 | printf("this do not points to the same location"); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /07 arrays/02 multiplication table.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int mul[10]; 6 | int n; 7 | 8 | printf("------------Multiplication Table of Numbering------------\n"); 9 | printf("\n"); 10 | 11 | printf("Enter the value of numbering table: "); 12 | scanf("%d", &n); 13 | 14 | printf("\n"); 15 | 16 | for(int i=0; i<10; i++) 17 | { 18 | mul[i] = n*(i+1); 19 | printf("The Multiplication of %dx%d = %d\n",n, i+1, mul[i]); 20 | } 21 | printf("\n"); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /07 arrays/03 reverse array by function.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/07 arrays/03 reverse array by function.c -------------------------------------------------------------------------------- /07 arrays/04 multiple table.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void table(int *mulTable, int num, int n) 4 | { 5 | printf("the multiplication table of %d is:\n\n", num); 6 | for(int i=0; i 2 | 3 | int main() 4 | { 5 | int i, j, k; 6 | int arr[2][3][4]; 7 | 8 | for(i=0; i<2; i++) 9 | { 10 | for(j=0; j<3; j++) 11 | { 12 | for(k=0; j<4; j++) 13 | { 14 | printf("the address of %d %d %d is %u\n", i, j, k, &arr[i][j][k]); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /07 arrays/array in function.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void printArray(int *ptr, int n) 4 | { 5 | for(int i = 0; i 2 | 3 | int main() 4 | { 5 | int arr[4]; 6 | 7 | /* arr[0] = 49; 8 | arr[1] = 90; 9 | arr[2] = 20; 10 | arr[3] = 60;*/ 11 | 12 | printf("Enter the number of student 1 marks:"); 13 | scanf("%d", &arr[0]); 14 | printf("Enter the number of student 2 marks:"); 15 | scanf("%d", &arr[1]); 16 | printf("Enter the number of student 3 marks:"); 17 | scanf("%d", &arr[2]); 18 | printf("Enter the number of student 4 marks:"); 19 | scanf("%d", &arr[3]); 20 | 21 | printf("the marks of students are %d %d %d and %d", arr[0], arr[1], arr[2], arr[3]); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /07 arrays/input using loops.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int marks[5]; 6 | 7 | for(int i = 0; i<5; i++) 8 | { 9 | printf("Enter the marks of student %d: ", i+1); 10 | scanf("%d", &marks[i]); 11 | } 12 | 13 | printf("\n\n"); 14 | 15 | for(int i = 0; i<5; i++) 16 | { 17 | printf("the marks of student %d is %d\n", i+1, marks[i]); 18 | 19 | } 20 | 21 | return 0; 22 | } 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /07 arrays/multi dimensional array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int students, subjects; 6 | students = 3; 7 | subjects = 5; 8 | 9 | int marks[3][5]; 10 | for(int i=0; i 2 | 3 | int main() 4 | { 5 | char s[30]; 6 | 7 | printf("Enter your name: "); 8 | gets(s); 9 | 10 | printf("mobile no: "); 11 | gets(s); 12 | puts(s); 13 | //printf("your name is %s", s); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /08 strings/gets & puts.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/08 strings/gets & puts.exe -------------------------------------------------------------------------------- /08 strings/gets & puts.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/08 strings/gets & puts.o -------------------------------------------------------------------------------- /08 strings/input string.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char s[30]; 6 | 7 | printf("Enter your name: "); 8 | scanf("%s", s); 9 | 10 | printf("your name is %s", s); 11 | 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /08 strings/str cat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char st1[30] = "Hello "; 7 | char st2[20] = "Muhammad Asif"; 8 | 9 | strcat(st1, st2); 10 | //strcat add the multiple string to one function.. 11 | 12 | printf("%s", st1); 13 | } 14 | -------------------------------------------------------------------------------- /08 strings/str cmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char st1[30] = "Hello"; 7 | char st2[20] = "Asif"; 8 | 9 | int comp = strcmp(st1, st2); 10 | //strcom compares the ascii value of two strings... 11 | 12 | printf("the compare betwn st1 and st2 is %d", comp); 13 | } 14 | -------------------------------------------------------------------------------- /08 strings/str cmp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/08 strings/str cmp.exe -------------------------------------------------------------------------------- /08 strings/str cmp.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/08 strings/str cmp.o -------------------------------------------------------------------------------- /08 strings/string in easy way.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char *ptr = "Muhammad Asif"; 6 | 7 | printf("%s", ptr); 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /08 strings/string with loop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char str[] = {"harry"}; 6 | char *ptr = str; 7 | 8 | while(*ptr!='\0') 9 | { 10 | printf("%c", *ptr); 11 | ptr++; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /08 strings/strlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char *st = "Muhammad Asif"; 7 | int a = strlen(st); 8 | 9 | printf("the length of string st is %d", a); 10 | } 11 | -------------------------------------------------------------------------------- /08 strings/strspy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char *first = "Muhammad Asif"; 7 | char second[30]; 8 | 9 | strcpy(second, first); // strcpy is copy the first string to second 10 | printf("now the second string is %s", second); 11 | } 12 | -------------------------------------------------------------------------------- /09 structure/01 two dimensional vector.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct vector 5 | { 6 | int x2; 7 | float y2; 8 | }; 9 | 10 | 11 | int main () 12 | { 13 | printf("---------------Creating Two Dimensional Vector---------------\n\n"); 14 | struct vector v1, v2; 15 | 16 | v1.x2 = 30; 17 | v1.y2 = 50.2; 18 | printf("In vector 1 x2 is %d and y2 is %0.2f\n\n", v1.x2, v1.y2); 19 | 20 | v2.x2 = 73; 21 | v2.y2 = 24.93; 22 | printf("In vector 2 x2 is %d and y2 is %0.2f\n\n", v2.x2, v2.y2); 23 | 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /09 structure/02 sum in function.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct vector 5 | { 6 | int x2; 7 | float y2; 8 | }; 9 | struct vector sumVector(struct vector v1, struct vector v2) 10 | { 11 | struct vector result; 12 | result.x2 = v1.x2 + v2.x2; 13 | result.y2 = v1.y2 + v2.y2; 14 | return result; 15 | }; 16 | int main () 17 | { 18 | printf("---------------Creating Two Dimensional Vector sum by function in struct---------------\n\n"); 19 | struct vector v1, v2, sum; 20 | 21 | v1.x2 = 30; 22 | v1.y2 = 50.2; 23 | printf("In vector 1 x2 is %d and y2 is %0.2f\n\n", v1.x2, v1.y2); 24 | 25 | v2.x2 = 73; 26 | v2.y2 = 24.93; 27 | printf("In vector 2 x2 is %d and y2 is %0.2f\n\n", v2.x2, v2.y2); 28 | 29 | sum = sumVector(v1, v2); 30 | printf("x dim of result is %d and y dim result is %d\n\n", sum.x2, sum.y2); 31 | 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /09 structure/03 date & time comparision.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef struct date{ 5 | int date; 6 | int month; 7 | int year; 8 | }date; 9 | 10 | int dateCmp(date d1, date d2){ 11 | // Make decision on the basis of Year comparison 12 | if(d1.year>d2.year){ 13 | return 1; 14 | } 15 | if(d1.yeard2.month){ 21 | return 1; 22 | } 23 | if(d1.monthd2.date){ 29 | return 1; 30 | } 31 | if(d1.date 2 | #include 3 | 4 | struct office 5 | { 6 | int code; 7 | float salary; 8 | char name[200]; 9 | }; 10 | 11 | int main () 12 | { 13 | struct office employ[10]; 14 | 15 | printf("Enter employer name: "); 16 | gets(employ[0].name); 17 | printf("Enter employ code: "); 18 | scanf("%d", &employ[0].code); 19 | printf("Enter the amount of salary: "); 20 | scanf("%f", &employ[0].salary); 21 | 22 | printf("\n"); 23 | 24 | printf("Enter employer name: "); 25 | gets(employ[1].name); 26 | puts(employ[1].name); 27 | printf("Enter employ code: "); 28 | scanf("%d", &employ[1].code); 29 | printf("Enter the amount of salary: "); 30 | scanf("%f", &employ[1].salary); 31 | 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /09 structure/function in struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct office 5 | { 6 | int code; 7 | float salary; 8 | char name[200]; 9 | }; 10 | 11 | void show(struct office emp) 12 | { 13 | printf("\n"); 14 | printf("the code of employee is: %d\n", emp.code); 15 | printf("the salary of employee is: %0.2f\n", emp.salary); 16 | printf("the name of employee is: %s", emp.name); 17 | printf("\n"); 18 | } 19 | 20 | int main () 21 | { 22 | printf("---------using show function in structure------------"); 23 | 24 | struct office a; 25 | 26 | a.code = 101; 27 | a.salary = 3444.50; 28 | strcpy(a.name, "Muhammad asif"); 29 | printf("\n"); 30 | 31 | show(a); 32 | 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /09 structure/input struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct student 5 | { 6 | char name[30], group[30]; 7 | int roll; 8 | int fee; 9 | }; 10 | 11 | int main() 12 | { 13 | struct student a, b, c; 14 | 15 | printf("Enter the name of student: "); 16 | gets(a.name); 17 | puts(a.name); 18 | printf("Enter the roll number: "); 19 | scanf("%d", &a.roll); 20 | printf("Enter the student monthly fee: "); 21 | scanf("%d", &a.fee); 22 | printf("\n"); 23 | 24 | 25 | printf("Enter the name of student: \n"); 26 | gets(b.name); 27 | puts(b.name); 28 | printf("Enter the roll number: "); 29 | scanf("%d", &b.roll); 30 | printf("Enter the student monthly fee: "); 31 | scanf("%d", &b.fee); 32 | printf("\n"); 33 | 34 | 35 | printf("Enter the name of student: "); 36 | gets(c.name); 37 | printf("Enter the roll number: "); 38 | scanf("%d", &c.roll); 39 | printf("Enter the student monthly fee: "); 40 | scanf("%d", &c.fee); 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /09 structure/intro struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct employ 5 | { 6 | int code; 7 | char name[20]; 8 | float salary; 9 | }; 10 | 11 | int main() 12 | { 13 | struct employ e1; 14 | e1.code = 1540; 15 | strcpy(e1.name, "Muhammad Asif"); 16 | e1.salary = 25000; 17 | 18 | 19 | printf("the Employer code is %d\n", e1.code); 20 | printf("the Employer name is %s\n", e1.name); 21 | printf("the Employer salary is %0.2f", e1.salary); 22 | printf("\n\n"); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /09 structure/other way array in struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct office 5 | { 6 | int code; 7 | float salary; 8 | char name[200]; 9 | }; 10 | 11 | int main () 12 | { 13 | struct office employ = {100, 3444.50, "Asif"}; 14 | 15 | printf("your code is %d\n", employ.code); 16 | printf("your salary is %0.2f\n", employ.salary); 17 | printf("your name is %s", employ.name); 18 | printf("\n"); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /09 structure/pointer to struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | struct office 5 | { 6 | int code; 7 | float salary; 8 | char name[200]; 9 | }; 10 | 11 | int main () 12 | { 13 | struct office a; 14 | struct office *ptr; 15 | ptr = &a; 16 | 17 | (*ptr).code = 101; 18 | printf("ptr value is %d\n", (*ptr).code); 19 | printf("%d\n", a.code); 20 | 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /09 structure/typedef in struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | //typedef is an alias, like a nick name, which is used for extra variables in data types. 5 | 6 | typedef struct office //declare typedef in structure as extra 7 | { 8 | int code; 9 | float salary; 10 | char name[200]; 11 | }extra; //extra is typdef custom data type 12 | 13 | void show(extra emp) 14 | { 15 | printf("\n"); 16 | printf("the code of employee is: %d\n", emp.code); 17 | printf("the salary of employee is: %0.2f\n", emp.salary); 18 | printf("the name of employee is: %s", emp.name); 19 | printf("\n"); 20 | } 21 | 22 | int main () 23 | { 24 | printf("---------using typedef in structure------------"); 25 | 26 | //struct office a; 27 | extra a; // struct office = extra. replacing struct in typedef custom data type 28 | 29 | a.code = 101; 30 | a.salary = 3444.50; 31 | strcpy(a.name, "Muhammad asif"); 32 | printf("\n"); 33 | 34 | show(a); 35 | 36 | 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /C project/ATM BANKING SYSTEM/ATM_BANKING_IN_C.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void main(){ 5 | 6 | float x, y; 7 | char ch, name[20]; 8 | 9 | system("cls"); 10 | printf("\t\t---------WELCOME TO DIGITAL ATM SERVICE---------\n\n"); 11 | printf("\t\tEnter Your Account Name: "); 12 | gets(name); 13 | 14 | system("cls"); 15 | printf("\t\t------------WELCOME TO YOUR ACCOUNT %s-------------\n\n", name); 16 | printf("\t\tEnter Your Initial Amount: "); 17 | scanf("\t\t%f", &x); 18 | 19 | void sub_main() 20 | { 21 | 22 | system("cls"); 23 | printf("\t\tCHOOSE YOUR OPTIONS-->\n\n"); 24 | printf("\t\tc for CREDIT\n"); 25 | printf("\t\td for DEBIT\n"); 26 | printf("\t\tb for BALANCE\n"); 27 | printf("\t\tu for DEVELOPER\n"); 28 | scanf("\n%c", &ch); 29 | } 30 | 31 | sub_main(); 32 | 33 | switch (ch) 34 | { 35 | case 'c': 36 | system("cls"); 37 | printf("\nEnter Your CREDIT Amount: "); 38 | scanf("%f", &y); 39 | x = x+y; 40 | printf("your updated amount is %0.2f", x); 41 | 42 | printf("\n\n\t\t------PRESS ANY KEY TO MAIN MENU-------"); 43 | getch(); 44 | break; 45 | 46 | case 'd': 47 | system("cls"); 48 | printf("\nEnter Your DEBIT Amount: "); 49 | scanf("%f", &y); 50 | if(x>=y){ 51 | x = x - y; 52 | printf("your updated amount is %0.2f", x); 53 | } 54 | else{ 55 | printf("Insufficient Balance In Your Account"); 56 | } 57 | 58 | printf("\n\n\t\t------PRESS ANY KEY TO MAIN MENU-------"); 59 | getch(); 60 | break; 61 | 62 | case 'b': 63 | system("cls"); 64 | printf("\nAccount name: %s\n", name); 65 | printf("Amount in your Account is %0.2f\n\n", x); 66 | printf("*****Thanks for Connecting us*****"); 67 | 68 | printf("\n\n\t\t------PRESS ANY KEY TO MAIN MENU-------"); 69 | getch(); 70 | 71 | break; 72 | 73 | case 'u': 74 | system("cls"); 75 | printf("\nAuthor: Muhammad Asif\n"); 76 | printf("Professional Front-End Engineer\n"); 77 | printf("alexasifhhossain@gmail.com\n"); 78 | printf("Dhaka, Bangladesh"); 79 | printf("\n\n\t\t------PRESS ANY KEY TO MAIN MENU-------"); 80 | getch(); 81 | 82 | break; 83 | 84 | default: 85 | 86 | printf("\nChoose Other Options\n\n"); 87 | 88 | break; 89 | } 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /C project/ATM BANKING SYSTEM/ATM_BANKING_IN_C.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/ATM BANKING SYSTEM/ATM_BANKING_IN_C.exe -------------------------------------------------------------------------------- /C project/ATM BANKING SYSTEM/ATM_BANKING_IN_C.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/ATM BANKING SYSTEM/ATM_BANKING_IN_C.o -------------------------------------------------------------------------------- /C project/Calender App in C/Calender_App_C_Programming.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | //this function calculation for correct calender days of any months of year 4 | int firstDayOfYear(int year){ 5 | int day = (year*365 + ((year-1) / 4) - ((year-1) / 100) + ((year-1) / 400)) % 7; 6 | return day; 7 | } 8 | 9 | int main(){ 10 | 11 | char *month[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; 12 | int daysOfMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 13 | int i, j, Days, week = 0, space = 0, year; 14 | 15 | printf("Enter your Favorite year: \n"); 16 | scanf("%d", &year); 17 | system("cls"); 18 | printf("_________________Welcome to %d________________", year); 19 | 20 | //code for leap year 21 | if((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)){ 22 | daysOfMonth[1] = 29; 23 | } 24 | 25 | // For the First day of any year 26 | week = firstDayOfYear(year); 27 | for(i = 0; i < 12; i++) 28 | { 29 | printf("\n\n\n-------------------%s--------------------\n", month[i]); 30 | printf("\n Sun Mon Tue Wed Thu Fri Sat\n\n"); 31 | 32 | for (space = 1; space <=week; space++) 33 | { 34 | printf(" "); 35 | } 36 | 37 | Days = daysOfMonth[i]; 38 | for (j = 1; j <= Days; j++) 39 | { 40 | printf("%6d", j); 41 | week++; 42 | if(week > 6){ 43 | week = 0; 44 | printf("\n"); 45 | } 46 | } 47 | 48 | 49 | } 50 | printf("\n\n\nMade By Muhammad asif (Web Developer)\n"); 51 | printf("Gmail: alexasifhhossain@gmail.com\n"); 52 | printf("linkedin: mohammadasif10\n"); 53 | printf("Institute of Science & Technology\n\n\n"); 54 | 55 | 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /C project/Calender App in C/Calender_App_C_Programming.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/Calender App in C/Calender_App_C_Programming.exe -------------------------------------------------------------------------------- /C project/Calender App in C/Calender_App_C_Programming.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/Calender App in C/Calender_App_C_Programming.o -------------------------------------------------------------------------------- /C project/Phone Book system in C/contact.txt: -------------------------------------------------------------------------------- 1 | md asif 2 | asif 6421648 3 | asif muhammad 4 | asif asif 5 | muhammad 6 | asif 7 | asif 8 | 9 | asif 10 | 11 | -------------------------------------------------------------------------------- /C project/Phone Book system in C/simplephone.c: -------------------------------------------------------------------------------- 1 | #include 2 | void add(); 3 | void search(); 4 | void delet(); 5 | void view(); 6 | void about(); 7 | 8 | void main() 9 | { 10 | system("cls"); 11 | printf("\t*****PHONE BOOK*****\n"); 12 | printf("\t 1. Add Contact\n"); 13 | printf("\t 2. Search Contact\n"); 14 | printf("\t 3. Delete Contact\n"); 15 | printf("\t 4. View All Contact\n"); 16 | printf("\t 5. About developer\n"); 17 | printf("\t 6. Exit\n"); 18 | printf("\nEnter Your Choice:-"); 19 | int option; 20 | scanf("%d",&option); 21 | switch(option) 22 | { 23 | case 1:a 24 | add(); 25 | break; 26 | case 2: 27 | search(); 28 | break; 29 | case 3: 30 | delet(); 31 | break; 32 | case 4: 33 | view(); 34 | break; 35 | case 5: 36 | about(); 37 | break; 38 | case 6: 39 | exit(0); 40 | default: 41 | main(); 42 | } 43 | } 44 | void add() 45 | { 46 | FILE *fp; 47 | fp=fopen("contact.txt","a+"); 48 | system("cls"); 49 | printf("\t*****ADD CONTACT*****"); 50 | printf("\n\tName :-\n"); 51 | char name[20]; 52 | scanf("%s", name); 53 | printf("\n\tMob No. :- " ); 54 | char mob[20]; 55 | scanf(mob); 56 | fprintf(fp,"%s\n",name); 57 | fprintf(fp, "%s\n", mob); 58 | fclose(fp); 59 | printf("\n\tPRESS ANY KEY TO CONTINUE"); 60 | getc; 61 | main(); 62 | } 63 | void search() 64 | { 65 | FILE *fp; 66 | fp=fopen("contact.txt","r"); 67 | system("cls"); 68 | printf("\t*****SEARCH CONTACT*****"); 69 | printf("\n\t Enter Name :-"); 70 | char name[20]; 71 | scanf("%s",name); 72 | char name1[20],mob[20]; 73 | while(fscanf(fp,"%s %s",name1,mob)!=EOF) 74 | { 75 | if(strcmp(name,name1)==0) 76 | { 77 | printf("\n\tNAME :- %s\n",name1); 78 | printf("\n\tMOB NO. :- %s\n",mob); 79 | } 80 | } 81 | fclose(fp); 82 | printf("\n\tPRESS ANY KEY TO CONTINUE"); 83 | getc; 84 | main(); 85 | } 86 | void delet() 87 | { 88 | FILE *fp,*fp1; 89 | fp=fopen("contact.txt","r+"); 90 | fp1=fopen("temp.txt","w"); 91 | system("cls"); 92 | printf("\t*****DELETE CONTACT*****"); 93 | printf("\n\t Enter Name :-"); 94 | char name[20]; 95 | scanf("%s",name); 96 | char name1[20],mob[20]; 97 | while(fscanf(fp,"%s %s",name1,mob)!=EOF) 98 | { 99 | if(strcmp(name,name1)==0) 100 | { 101 | continue; 102 | } 103 | fprintf(fp1,"%s %s\n",name1,mob); 104 | } 105 | fclose(fp); 106 | fclose(fp1); 107 | fp=fopen("contact.txt","w"); 108 | fp1=fopen("temp.txt","r"); 109 | while(fscanf(fp1,"%s %s",name1,mob)!=EOF) 110 | { 111 | 112 | fprintf(fp,"%s %s\n",name1,mob); 113 | } 114 | fclose(fp); 115 | fclose(fp1); 116 | remove("temp.txt"); 117 | printf("\n\tPRESS ANY KEY TO CONTINUE"); 118 | getc; 119 | main(); 120 | } 121 | void view() 122 | { 123 | FILE *fp; 124 | fp=fopen("contact.txt","r"); 125 | system("cls"); 126 | printf("\t*****ALL CONTACTS*****"); 127 | char name1[20],mob[20]; 128 | while(fscanf(fp,"%s %s",name1,mob)!=EOF) 129 | { 130 | printf("\n\t NAME :- %s",name1); 131 | printf("\n\t MOB NO. :- %s",mob); 132 | } 133 | fclose(fp); 134 | printf("\n\tPRESS ANY KEY TO CONTINUE"); 135 | getc; 136 | main(); 137 | } 138 | void about() 139 | { 140 | system("cls"); 141 | printf("\n\t this project is made by MUHAMMAD ASIF\n"); 142 | printf("\t Profession Web Developer\n"); 143 | printf("\t alexasifhhossain@gmail.com\n"); 144 | printf("\t Institute of science & technology\n"); 145 | 146 | printf("\n\tPRESS ANY KEY TO CONTINUE"); 147 | getc; 148 | main(); 149 | } 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | -------------------------------------------------------------------------------- /C project/Phone Book system in C/simplephone.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/Phone Book system in C/simplephone.exe -------------------------------------------------------------------------------- /C project/Phone Book system in C/simplephone.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/Phone Book system in C/simplephone.o -------------------------------------------------------------------------------- /C project/Stop Watch in C/Stop_Watch_by_C_language.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include //for linux user use this 4 | #define CYCLE 60 5 | //#define sleep(x) Sleep(x*1000) //for windows user use this 6 | 7 | int main() 8 | { 9 | int hour, minute, second; 10 | int h = 0, m = 0, s = 0; 11 | printf("Enter hour: \n"); 12 | scanf("%d", &hour); 13 | printf("Enter minute: \n"); 14 | scanf("%d", &minute); 15 | printf("Enter second: \n"); 16 | scanf("%d", &second); 17 | 18 | while(1) 19 | { 20 | printf("\n\n---------------DIGITAL STOP WATCH------------------\n\n"); 21 | printf(" %.2d:%.2d:%.2d\n \n", h, m, s); 22 | printf("###################################################"); 23 | 24 | if(h == hour && m == minute && s == second) 25 | { 26 | break; 27 | } 28 | else 29 | { 30 | system("cls"); 31 | } 32 | s++; 33 | sleep(1); 34 | if(s == CYCLE) 35 | { 36 | m++; 37 | s = 0; 38 | } 39 | if(m == CYCLE) 40 | { 41 | h++; 42 | m = 0; 43 | } 44 | 45 | } 46 | printf("\n\nMade By Muhammad asif (Web Developer)\n"); 47 | printf("Gmail: alexasifhhossain@gmail.com\n"); 48 | printf("linkedin: mohammadasif10\n"); 49 | printf("Institute of Science & Technology\n\n"); 50 | 51 | return 0; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /C project/Stop Watch in C/Stop_Watch_by_C_language.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/Stop Watch in C/Stop_Watch_by_C_language.exe -------------------------------------------------------------------------------- /C project/Stop Watch in C/Stop_Watch_by_C_language.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/C project/Stop Watch in C/Stop_Watch_by_C_language.o -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # programming C and C++ 2 | C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on. C programming is an excellent language to learn to program for beginners.
3 | C++ is most useful language for Game Developing, Desktop app, operating systems etc. It is a compiler language. which is developed from C. It is faster than C Program 4 | This repository will guide you to learn C programming basic with examples and projects. I have used C++ for Problem Solving knowledge, Data Structure and Algorithm 5 | 6 | ## Why Learn C/C++ Programming? 7 | This language will helps you to understand the internal architecture of a computer, how computer stores and retrieves information.
After learning this language, it will be much easier to learn other programming languages like Java, Python, php, perl, ruby, javascript etc.
Opportunity to work on open source projects. Some of the largest open-source projects such as Linux kernel, Python interpreter, SQLite database, etc. are written in C and C++ 8 | 9 | ## How Computer Execute the code? 10 | The code we write in the IDE or Code Editor to execute is called Source Code. The Traslator Program convert the source code to Binary Code and our computer understand this Binary code. 11 | 12 | Translator Program is 3 Types:- 13 | - Assembly 14 | - Compiler 15 | - Interpreter 16 | 17 | **Compiler pragramming language:** C, C++, Objective-C, C#, Pascal. The compiler Read the Source code. If there is an error, The compiler show us list of Errors and If there is no Error the compiler convert the codes to Object code. It is fast 18 | 19 | **Interpreter Programming Language:** Python, PHP, Javascript, Perl, Ruby. The Interpreter works like same as compiler do. But It reads code line by line and give output from it. it is slow 20 | 21 | ## Header Files 22 | It is very Important to have proper knowledge about Header Files. Because all the functions are include in header files. Otherwise the functions are don't execute properly. 23 | 24 | **C header files:** 25 | 26 | **C++ header files:** 27 | 28 | 29 | ## Classification 30 | - Introduction 31 | - Flow Control 32 | - Function 33 | - Recursion 34 | - Arrays 35 | - Pointers 36 | - Strings 37 | - Structure and union 38 | - File I/O 39 | - Additional Topics 40 | - Programming Examples 41 | - simple Projects 42 | 43 | ## Projects 44 | - [ATM Banking System](./C%20project/ATM%20BANKING%20SYSTEM/ATM_BANKING_IN_C.c) 45 | - [Calender App](C%20project/Calender%20App%20in%20C/Calender_App_C_Programming.c) 46 | - [Phone Book System](C%20project/Phone%20Book%20system%20in%20C/contact.txt) 47 | - [Stop Watch](C%20project/Stop%20Watch%20in%20C/Stop_Watch_by_C_language.c) 48 | 49 | ## Tools 50 | - Visual Studio Code 51 | - CodeBlocks 52 | 53 | ## Resources 54 | - [ANCII C Programming Book](https://books.google.com.bd/books?id=AokcsKn-1iIC&printsec=copyright#v=onepage&q&f=false) 55 | - [Code With Harry -Youtube channel](https://youtu.be/ZSPZob_1TOk?list=LL) 56 | - [GeekforGeeks](https://www.geeksforgeeks.org/c-programming-language/) 57 | - [Official C Programming Documentation](http://www.open-std.org/jtc1/sc22/wg14/) 58 | 59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /data_structure_algorithm/binary_search.cpp: -------------------------------------------------------------------------------- 1 | // Binary Search in C++ 2 | // Binary search is fast than linear. It divided the number from middle and search it. when using binary search always the number must be sorted. 3 | 4 | #include 5 | using namespace std; 6 | 7 | int binary(int arr[], int x, int low, int high){ 8 | while (low <= high) 9 | { 10 | int mid = low + (high - low) / 2; 11 | if(arr[mid] == x){ 12 | return mid; 13 | } 14 | if(arr[mid] < x){ 15 | low = mid + 1; 16 | } 17 | else{ 18 | high = mid - 1; 19 | } 20 | } 21 | return -1; 22 | 23 | } 24 | 25 | int main(void){ 26 | system("cls"); 27 | int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; 28 | int x = 5; 29 | int n = sizeof(arr) / sizeof(arr[0]); 30 | int result = binary(arr, x, 0, n-1); 31 | 32 | if(result == -1){ 33 | cout << "element not found"; 34 | } 35 | else{ 36 | cout << "element found on " << result; 37 | } 38 | } -------------------------------------------------------------------------------- /data_structure_algorithm/binary_search.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/data_structure_algorithm/binary_search.exe -------------------------------------------------------------------------------- /data_structure_algorithm/linear_search.cpp: -------------------------------------------------------------------------------- 1 | // the linear search finds the desire output by index number.Linear search is a sequential searching algorithm where we start from one end and check every element of the list until the desired element is found. 2 | 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | int search(int array[], int n, int x) { 8 | 9 | // Going through array sequencially 10 | for (int i = 0; i < n; i++) 11 | if (array[i] == x) 12 | return i; 13 | return -1; 14 | } 15 | 16 | int main() { 17 | int array[] = {2, 4, 0, 1, 9}; 18 | int x = 1; 19 | int n = 6; 20 | 21 | int result = search(array, n, x); 22 | 23 | (result == -1) ? cout << "Element not found" : cout << "Element found at index: " << result; 24 | } 25 | 26 | // this algorithm Time Complexity is O(n) - Beacause the loop is depend on n value. 27 | // space complexity is O(1) - In the search function 3 arguments ar constant, so we don't calculate them. in for loop there is one int i. and it take space 4, whatever the value is. so space complexity is O(1) 28 | -------------------------------------------------------------------------------- /data_structure_algorithm/linear_search.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/data_structure_algorithm/linear_search.exe -------------------------------------------------------------------------------- /data_structure_algorithm/selection_sort.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | void selection_sort(int a[], int n){ 7 | int i, j, min_idx, temp; 8 | 9 | for(i = 0; i < n - 1; i++){ 10 | min_idx = i; 11 | for(j = i + 1; j < n; j++){ 12 | if(a[j] < a[min_idx]){ 13 | min_idx = j; 14 | } 15 | } 16 | if(min_idx != i){ 17 | temp = a[i]; 18 | a[i] = a[min_idx]; 19 | a[min_idx] = temp; 20 | } 21 | } 22 | } 23 | void printArr(int a[], int size){ 24 | int i; 25 | for(i = 0; i < size; i++) 26 | cout << a[i] << " "; 27 | cout << endl; 28 | } 29 | 30 | int main(){ 31 | system("cls"); 32 | // int a[] = {54, 32, 20, 34, 10, 3, 94}; 33 | int a[5]; 34 | // we are taking random array inputs from user 35 | cout << "Input random input for sorting array" << endl; 36 | for(int k = 0; k < sizeof(a) / sizeof(a[0]); k++){ 37 | cin >> a[k]; 38 | 39 | } 40 | int n = sizeof(a) / sizeof(a[0]); 41 | selection_sort(a, n); 42 | cout << "Sorted array: \n"; 43 | printArr(a, n); 44 | return 0; 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /data_structure_algorithm/selection_sort.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/data_structure_algorithm/selection_sort.exe -------------------------------------------------------------------------------- /data_structure_algorithm/space_complexity.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Space Complexity Or Memory Complexity 3 | _ 4 | low / \ High 5 | ! / \ ! 6 | ! / \ ! 7 | ! / Register \ ! 8 | ! /-------------\ ! 9 | ! / Case Level 1 \ ! 10 | ! capacity /-------------------\ speed ! 11 | ! / Cash Level 2 \ ! 12 | ! /-------------------------\ ! 13 | ! / Ram \ ! 14 | ! /-------------------------------\ ! 15 | ! / Virtual Memory \ ! 16 | High /-------------------------------------\ Low 17 | */ 18 | 19 | /*register, case level 1, cash level 2 stays in the processor 20 | Ram - external memory 21 | virtual memory - Hard disk 22 | always we try to run the program into ram. but when ram has not much space the program data store into virtual memory 23 | 24 | we know that, we have to run multiple program in our operating system. That's why memory is very valuable for program. So our goal should be to have less memory in the program. So space complexity is so important for any program. 25 | 26 | */ 27 | // space complexity O(n^2) 28 | #include 29 | #include 30 | #include 31 | using namespace std; 32 | 33 | int main(){ 34 | 35 | int i, j, n; 36 | int a[5][5], b[5][5], s[5][5]; 37 | // when use multi dimensional array, must declare their array size, otherwise error will throw 38 | cout << "input n_"; 39 | cin >> n; 40 | for(i = 0; i < n; i++){ 41 | for(j = 0; j < n; j++){ 42 | s[i][j] = a[i][j] + b[i][j]; 43 | cout << "s[i][j] = " << s[i][j] << endl; 44 | } 45 | 46 | } 47 | 48 | 49 | return 0; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /data_structure_algorithm/space_complexity.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/data_structure_algorithm/space_complexity.exe -------------------------------------------------------------------------------- /data_structure_algorithm/time_complexity.cpp: -------------------------------------------------------------------------------- 1 | /* Time Complexity depends on some operations -- 2 | 1. assignment operation -> x = 10 3 | 2. comparision operatin -> a > b 4 | 3. mathmatical operation -> a + b, a -b 5 | 4. function call and it's inside work -> function() 6 | and include all the operations 7 | */ 8 | 9 | #include 10 | #include 11 | using namespace std; 12 | 13 | int main(){ 14 | 15 | // 1. Time Complexity O(1) 16 | // O(n) -> When the number of operations in the program does not depend on the input and the number of operations is constant, we call it O(n).if any problem has one assignment operation then the Time Complexity will be O(1). Example-- 17 | int n1, n2, result1; 18 | n1 = 10; // 1 assignment operation 19 | n2 = 20; // 1 assignment operation 20 | result1 = n1 + n2; // 2 assignment operation =, + 21 | cout << "result no 1: " << result1 <> n3; 31 | result2 = n3 * (n3 + 1) / 2; //here 1 assignment and 3 mathmatical operation = 4 operation 32 | cout << "result no 2: " << result2 << endl; 33 | cout << endl; 34 | //so the Time Complexity will be O(1). whaterver the n value is, the operation is constant here too. 35 | 36 | 37 | // now I will solve the same type problem in loop. the output will be linear type. But the Time Complexity will be same? what will be the complexity of this program? let's see. 38 | int i, n4, result3; 39 | cout << "type O(n) input_"; 40 | cin >> n4; 41 | result3 = 0; 42 | for(i = 0; i <= n4; i++){ 43 | result3 = result3 + 1; 44 | cout << "result no 3 = " << result3 << endl; 45 | } 46 | cout << endl; 47 | /*here we see that, if n value is 3, the loop will run 3 time and the operations will run 6 times. because there is two operations(=, +). 1 loop run = 2 operation run. 48 | if n = 1 operation = 2 49 | n = 5 operation = 10 50 | n = 10 operation = 20 51 | n is proportional to operation. so the operation is increasing by 2 times. so this 2 is constant we know and we can remove this 2. Now the complexity is O(n). 52 | */ 53 | 54 | 55 | // 3. Time Complexity O(n^2) -- The value of n will be the square of the number of operations 56 | int i2, j2, n5, count; 57 | cout << "Type O(n^2) input_"; 58 | cin >> n5; 59 | count = 0; 60 | for(i2 = 0; i2 < n5; i2++){ 61 | for(j2 = 0; j2 < n5; j2++){ 62 | count = count + 1; 63 | } 64 | } 65 | cout << "----result no 4----" << endl; 66 | cout << "n = " << n5 << ", count = " << count << endl; 67 | cout << endl; 68 | /* for two loop operation 69 | if n = 1 , count = 1 70 | n = 2, count = 4 71 | n = 3, count = 9, 72 | n = 10, count = 100 73 | we see that, the value of count is increasing by 2 muliplying, which i n^2. so the Time Complexity will be O(n^2). when the two loop will be depend on same value(n), then we can call it O(n^2), otherwise it will be O(n). Because the operation numbers are constant, whatever it is 2, 3, 4 etc. 74 | */ 75 | 76 | 77 | // 4. Time Complexity O(n^3) -- think about loop, The number of loops depends on the value of n. if the loop is 3 times and the nth value is 3 times the Time Complexity will be O(n^3) and the each operation will run for 3 times. that's the main fact-- 78 | int i3, j3, k3, n6, count2; 79 | cout << "Type O(n^3) input_"; 80 | cin >> n6; 81 | for(i3 = 0; i3 < n6; i3++){ 82 | for(j3 = 0; j3 < n6; j3++){ 83 | for(k3 = 0; k3 < n6; k3++){ 84 | count2 = count2 + 1; 85 | } 86 | } 87 | } 88 | cout << "----result no 5----" << endl; 89 | cout << "n = " << n6 << ", count = " << count2 << endl; 90 | // If we add another loop, the complexity will be O(n^4). Basically we don't use more complexity than O(n^3) in our program. So remember this. 91 | return 0; 92 | } 93 | 94 | /* 95 | how the Big O Increase? 96 | O(1) - there no change in time by increasing input value. whatever the input value the time is same and operation will be same. 97 | 98 | O(n) - The number of operations is proportional to N values. the operation and n will be same. so it will take equal time 99 | 100 | O(n^2) - The value of n will be the square of the number of operations. the operation numbers are multiply by 2 times. 101 | 102 | O(n^3) - this operation numbers are multiply by 3 times of n value. Takes more time to run. 103 | 104 | By mistake if you are using four nested loop, that mean's something is wrong and be carefull about that program. 105 | dont't try to memorize this algorithm, always practice, do code, mind it and this is good practice. 106 | 107 | */ 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /data_structure_algorithm/time_complexity.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/data_structure_algorithm/time_complexity.exe -------------------------------------------------------------------------------- /file Input & Output/file open.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | FILE *ptr; 6 | int num; 7 | char car; 8 | ptr = fopen("simple.txt", "r"); // "r" for reading the file 9 | 10 | fscanf(ptr, "%d", &num ); 11 | printf("the value of num is %d\n", num); 12 | fscanf(ptr, "%s", &car); 13 | printf("the word is %s", car); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /file Input & Output/file open.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/file Input & Output/file open.exe -------------------------------------------------------------------------------- /file Input & Output/file open.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/file Input & Output/file open.o -------------------------------------------------------------------------------- /file Input & Output/simple.txt: -------------------------------------------------------------------------------- 1 | 1202 -------------------------------------------------------------------------------- /problem_solving/ps01.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // int main() { 5 | // int a, b; 6 | // printf("Enter first number\n"); 7 | // scanf("%d", &a); 8 | // printf("Enter second number\n"); 9 | // scanf("%d", &b); 10 | // printf("The sum is %d\n", a + b); 11 | // return 0; 12 | // } 13 | // the int data calculates from -2pow31 to 2pow31. 14 | 15 | 16 | // int main(){ 17 | // long long a, b; 18 | // printf("enter no. 1\n"); 19 | // scanf("%lld", &a); 20 | // printf("enter no. 2\n"); 21 | // scanf("%lld", &b); 22 | // printf("the total is %lld", a * b); 23 | // return 0; 24 | // } 25 | // the long long data calculates from -2pow63 to 2pow63. 26 | 27 | 28 | int main(){ 29 | float a, b; 30 | printf("Enter float one "); 31 | scanf("%f", &a); 32 | printf("Enter float two "); 33 | scanf("%f", &b); 34 | printf("the total is %f", a / b); 35 | 36 | } 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /problem_solving/ps01.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/ps01.exe -------------------------------------------------------------------------------- /problem_solving/ps02.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | 6 | double area, pi, r; 7 | printf("Enter radius\n"); 8 | scanf("%lf", &r); 9 | pi = acos(-1.); 10 | area = pi * r * r; 11 | printf("the area is %lf", area); 12 | return 0; 13 | 14 | } -------------------------------------------------------------------------------- /problem_solving/ps02.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/ps02.exe -------------------------------------------------------------------------------- /problem_solving/ps03_odd_even.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(){ 6 | int a; 7 | printf("Enter a postive number\n"); 8 | scanf("%d", &a); 9 | if(a % 2 == 0){ 10 | printf("%d is Even number", a); 11 | } 12 | else{ 13 | printf("%d is odd number", a); 14 | } 15 | } -------------------------------------------------------------------------------- /problem_solving/ps03_odd_even.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/ps03_odd_even.exe -------------------------------------------------------------------------------- /problem_solving/ps04_leap_year.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(){ 6 | int year; 7 | printf("Enter your desire year "); 8 | scanf("%d", &year); 9 | if(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)){ 10 | printf("%d is a leap year", year); 11 | } 12 | else{ 13 | printf("%d is not a leap year", year); 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /problem_solving/ps04_leap_year.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/ps04_leap_year.exe -------------------------------------------------------------------------------- /problem_solving/ps05_simple_loop.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | int main(){ 7 | 8 | // print 1 to 10 9 | int a; 10 | for(a = 1; a <= 10; a++){ 11 | printf("%d\n", a); 12 | } 13 | 14 | 15 | //print 10 to 1 16 | printf("this is reverse\n"); 17 | for (a; a >= 1; a--){ 18 | printf("%d\n", a); 19 | } 20 | 21 | 22 | // print odd number from 1 to 10 23 | int odd; 24 | for(odd = 1; odd < 10; odd++){ 25 | if(odd % 2 != 0){ 26 | printf("%d\n", odd); 27 | } 28 | } 29 | 30 | 31 | //counts how many 2 divides 100 32 | int x, cnt; 33 | x = 100; 34 | cnt = 0; 35 | while(x % 2 == 0) 36 | { 37 | x = x / 2; 38 | cnt++; 39 | printf("%d: x = %d\n", cnt, x); 40 | } 41 | 42 | 43 | // print odd numbers from 1 to 10 44 | int odd; 45 | for(odd = 1; odd < 10; odd++){ 46 | if(odd % 2 == 0){ 47 | continue; 48 | // continue works like - where the condition is matched, it will skip those numbers. 49 | } 50 | printf("%d\n", odd); 51 | } 52 | 53 | 54 | // prints only 1, 2, 3 55 | for(int i = 1; i < 10; i++){ 56 | if (i > 3){ 57 | break; 58 | } 59 | printf("%d\n", i); 60 | } 61 | 62 | 63 | // takes input untill the input is 0 64 | int a; 65 | while(scanf("%d", &a)){ 66 | if(a == 0){ 67 | break; 68 | } 69 | printf("the number is %d\n", a); 70 | } 71 | 72 | 73 | // loop into the loop and the sum all numbers 74 | int i,j, sum, n; 75 | sum = 0; 76 | n = 15; 77 | for(i = 0; i < n; i++){ 78 | for(j = 0; j <= 1; j++){ 79 | sum += j; 80 | printf("%d\n", sum); 81 | } 82 | } 83 | 84 | 85 | // print the series 1+(1+2)+(1+2+3)+(1+2+3+4) 86 | int i,j,n; 87 | printf("no. of nth number_"); 88 | scanf("%d", &n); 89 | 90 | for(i=1; i<=n; i++){ 91 | printf("("); 92 | 93 | for(j=1;j<=i; j++){ 94 | printf("%d",j); 95 | if (j 2 | #include 3 | 4 | int main(){ 5 | 6 | // making PIRAMID by stars taking equal sapces to both sides 7 | // int row, col, n; 8 | 9 | // printf("Enter the no. of n_"); 10 | // scanf("%d", &n); 11 | // for(row = 1; row <= n; row++){ 12 | // for(col = 1; col <= n - row; col++){ 13 | // printf(" "); 14 | // } 15 | // for(col = 1; col <= 2 * row - 1; col++){ 16 | // printf("*"); 17 | // } 18 | // printf("\n"); 19 | // } 20 | 21 | // making PIRAMID BY character strings %c 22 | // int row, col, n; 23 | 24 | // printf("Enter the no. of n_"); 25 | // scanf("%d", &n); 26 | // for(row = 1; row <= n; row++){ 27 | // for(col = 1; col <= n - row; col++){ 28 | // printf(" "); 29 | // } 30 | // for(col = 1; col <= 2*row -1; col++){ 31 | // printf("%c", col+64); 32 | // } 33 | // printf("\n"); 34 | // } 35 | 36 | 37 | // making PIRAMID BY character in A, ABC, ABCDE Format 38 | // int row, col, n; 39 | 40 | // printf("Enter the no. of n_"); 41 | // scanf("%d", &n); 42 | // for(row = 1; row <= n; row++){ 43 | // for(col = 1; col <= n - row; col++){ 44 | // printf(" "); 45 | // } 46 | // for(col = 1; col <= 2*row -1; col++){ 47 | // printf("%c", 'A' + col -1); 48 | // } 49 | // printf("\n"); 50 | // } 51 | 52 | 53 | // making PIRAMID BY CHARACTER IN A, BB, CCC format 54 | int row, col, n; 55 | 56 | printf("Enter the no. of n_"); 57 | scanf("%d", &n); 58 | for(row = 1; row <= n; row++){ 59 | for(col = 1; col <= n - row; col++){ 60 | printf(" "); 61 | } 62 | for(col = 1; col <= 2*row -1; col++){ 63 | printf("%c", 'A' -1 + row); 64 | } 65 | printf("\n"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /problem_solving/ps06_piramid_pattern.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/ps06_piramid_pattern.exe -------------------------------------------------------------------------------- /problem_solving/ps07_array_string.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | // Problem 1: Print single word from a string 11 | 12 | // string is a single 13 | // gets() takes big inputs for string 14 | // stringstream operate string. as I put a string variable name 'line' to stringsteam as ss name. 15 | char line[100]; 16 | cout <<"enter words of line: "; 17 | gets(line); 18 | istringstream ss(line); 19 | string subs; 20 | // the result will be each word 21 | while(ss >> subs) 22 | { 23 | cout << "Substring: " << subs << endl; 24 | // endl = it uses for new line 25 | } 26 | 27 | //Problem 2: print single letter from a string 28 | // char is a string type array. take it print by single character 29 | char abc[20]; 30 | cout <<"Enter words of abc: "; 31 | gets(abc); 32 | istringstream ab(abc); 33 | char test; 34 | // the result will be each letter 35 | while(ab >> test){ 36 | cout << "abc single letter: " << test << endl; 37 | } 38 | 39 | 40 | 41 | } 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /problem_solving/ps07_array_string.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/ps07_array_string.exe -------------------------------------------------------------------------------- /problem_solving/ps08_string_problem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | 8 | // 1. Convert Decimal to Binary number 9 | // int main() 10 | // { 11 | // int num,arr[64]; 12 | // // cin -- its take input from users. it uses to take number input. 13 | // cin>>num; 14 | // int i=0,r; 15 | // while(num!=0) 16 | // { 17 | // r = num%2; //if num is 0 it the loop stop. if num is even number it will return 0 and if num is odd number it will return 1 18 | // arr[i++] = r; //here the r value stores to arr[i] 19 | // num /= 2; // num = num / 2; 20 | // } 21 | 22 | // for(int j=i-1;j>=0;j--){ 23 | // cout<> n; 44 | cout << n << " in binary = " << convert(n) << " in decimal" << endl; 45 | return 0; 46 | } 47 | 48 | 49 | -------------------------------------------------------------------------------- /problem_solving/ps08_string_problem.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/ps08_string_problem.exe -------------------------------------------------------------------------------- /problem_solving/string_library_function.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | 6 | int main(){ 7 | 8 | // strlen() - finds length from a string 9 | char ch[] = "Asif"; 10 | int len = strlen(ch); 11 | cout << "Length: " << len << endl; 12 | 13 | // strcpy() - copy a string. where we copy a string, that string variable must declare with storage size and put it empty; otherwise we will get error 14 | char cp[6]; 15 | strcpy(cp, ch); 16 | cout << "Copy: " << cp << endl; 17 | 18 | // strcat - It is a concatanation. first variable take the second variable value. 19 | char con[] = "web"; 20 | char cat[] = " developer"; 21 | strcat(con,cat); 22 | cout << "String Concatenation is: " << con << endl; 23 | 24 | // strupr() -- It is string uppercase function. 25 | strupr(con); 26 | cout << "Uppercase of con: " << con << endl; 27 | 28 | // strlwr() -- It is string lowercase function 29 | strlwr(con); 30 | cout << "Lowecase of con: " << con << endl; 31 | 32 | // strcmp -- It makes comparision between two strings 33 | 34 | char a[] = "a is lower"; 35 | char b[] = "b is lower"; 36 | 37 | int val = strcmp(a, b); 38 | 39 | if(val == 0){ 40 | cout << "strcmp ans: string are equal"; 41 | } 42 | else{ 43 | cout << "strcmp ans: they are not same"; 44 | } 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | } -------------------------------------------------------------------------------- /problem_solving/string_library_function.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsifOnTheCode/Cpp-and-projects/f8693402101261ae3b1f6e906292d46d72265bba/problem_solving/string_library_function.exe --------------------------------------------------------------------------------