├── CHAPTER 01 ├── 1st.c ├── harry.c ├── practice.c └── variables.c ├── CHAPTER 02 ├── instructioons.c └── practice_set.c ├── CHAPTER 03 ├── ascii.c ├── ascii.exe ├── ayush.c ├── ayush.exe ├── conditional_operators.c ├── conditional_operators.exe ├── if_basic.c ├── if_basic.exe ├── if_else_if.c ├── if_else_if.exe ├── incometax.c ├── incometax.exe ├── leap ├── leap_year.c ├── leap_year.exe ├── logical_opetaroes.c ├── logical_opetaroes.exe ├── practice.c ├── practice.exe ├── printf ├── switch_case.c ├── switch_case.exe └── tempCodeRunnerFile.c ├── CHAPTER 04 ├── break_statement.c ├── break_statement.exe ├── continue_statement.c ├── continue_statement.exe ├── dowhile.c ├── dowhile.exe ├── forloop.c ├── forloop.exe ├── increment_op.c ├── increment_op.exe ├── practice.c ├── practice.exe ├── practice2.c ├── practice2.exe ├── practice3.c ├── practice3.exe ├── practice4.c ├── practice4.exe ├── practice5.c ├── practice5.exe ├── practice6.c ├── practice6.exe ├── practiceset.c ├── practiceset.exe ├── tempCodeRunnerFile.c └── whihle loop.c ├── CHAPTER 05 ├── 01.c ├── 01.exe ├── 02.c ├── 02.exe ├── 03.c ├── 03.exe ├── change.c ├── change.exe ├── fibonacci.c ├── fibonacci.exe ├── fnction_inside_fnction.c ├── fnction_inside_fnction.exe ├── function.c ├── function.exe ├── practice.exe ├── prime_no_using_all_loops.c ├── prime_no_using_all_loops.exe ├── ptac.c ├── ptac.exe ├── quiz.c ├── quiz.exe ├── quiz2.c ├── quiz2.exe ├── recursion.c ├── recursion.exe ├── sum_function.c ├── sum_function.exe └── tempCodeRunnerFile.c ├── CHAPTER 06 ├── call_by_reference.c ├── call_by_reference.exe ├── call_by_value.c ├── call_by_value.exe ├── pointers.c ├── pointers.exe ├── practice_1.c ├── practice_1.exe ├── practice_2.c ├── practice_2.exe ├── practice_3.c ├── practice_3.exe ├── practice_4.c ├── practice_4.exe ├── practice_6.c ├── ptactice_5.c └── ptactice_5.exe ├── CHAPTER 07 ├── 2.c ├── 2.exe ├── 2D_array.c ├── 2D_array.exe ├── 3_dimensional_array.c ├── 3_dimensional_array.exe ├── array.c ├── array.exe ├── array_initiLIZE.c ├── array_initiLIZE.exe ├── array_inputs.c ├── array_inputs.exe ├── array_inputs_using_loops.c ├── array_inputs_using_loops.exe ├── pointer_arethimatic.c ├── pointer_arethimatic.exe ├── practice.c ├── practice.exe ├── practice2.c ├── practice2.exe ├── quiz.c ├── quiz.exe ├── quiz2.c ├── quiz2.exe ├── quiz3.c ├── quiz3.exe ├── reverse_array.c ├── reverse_array.exe ├── table.c ├── table.exe └── tempCodeRunnerFile.c ├── CHAPTER 08 ├── .vscode │ └── settings.json ├── convienentway_toprint_string.c ├── convienentway_toprint_string.exe ├── dif_bet_2_int_meth0ods.c ├── dif_bet_2_int_meth0ods.exe ├── gets_puts.c ├── gets_puts.exe ├── inputting_strings.c ├── inputting_strings.exe ├── practice1.c ├── practice1.exe ├── practice2.c ├── practice2.exe ├── practice3.c ├── practice3.exe ├── practice4.c ├── practice4.exe ├── practice5.c ├── practice5.exe ├── practice6.c ├── practice6.exe ├── strcat.c ├── strcat.exe ├── strcmp.c ├── strcmp.exe ├── strcpy.c ├── strcpy.exe ├── string.c ├── string.exe ├── stringusingptr.c ├── stringusingptr.exe ├── strlen.c └── strlen.exe ├── CHAPTER 09 ├── .vscode │ └── settings.json ├── another_way_to_inistrct.c ├── another_way_to_inistrct.exe ├── array_of_structure.c ├── array_of_structure.exe ├── function_to_struct.c ├── function_to_struct.exe ├── pointer_to_struct.c ├── pointer_to_struct.exe ├── prac1.c ├── prac1.exe ├── prac2.c ├── prac3.c ├── prac4.c ├── prac4.exe ├── prac5.c ├── prac6.c ├── prac6.exe ├── prac7.c ├── prac7.exe ├── special_ques.c ├── special_ques.exe ├── strct_input.c ├── structures.c ├── structures.exe ├── typedef.c └── typedef.exe ├── CHAPTER 10 ├── Basicsof_file.c ├── Basicsof_file.exe ├── a.txt ├── ayush.txt ├── b.txt ├── fgetc.c ├── fgetc_fputc.exe ├── file.txt ├── file_reading.c ├── file_reading.exe ├── file_writing.c ├── file_writing.exe ├── filw.txt ├── fputc.c ├── fputc.exe ├── getcdemo.txt ├── output.txt ├── ptr01.txt ├── ptr1.c ├── ptr1.exe ├── ptr2.c ├── ptr2.exe ├── ptr3.c ├── ptr3.exe ├── ptr4.c ├── ptr4.exe ├── putcdemo.txt ├── quikquiz.c ├── quikquiz.exe ├── read_whole_file.c ├── read_whole_file.exe ├── sample_txt.c └── zydus.txt ├── CHAPTER 11 ├── .vscode │ └── settings.json ├── 01_malloc.c ├── 01_malloc.exe ├── 02_calloc.c ├── 02_calloc.exe ├── 04_realloc.c ├── 04_realloc.exe ├── ptr1.c ├── quiz1.c ├── quiz1.exe ├── quiz2.c ├── quiz2.exe └── quiz3.c ├── PROJECT 1 ├── game.c ├── game.exe ├── random_nm.c └── random_nm.exe ├── PROJECT 2 ├── game.c └── game.exe └── README.md /CHAPTER 01/1st.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | printf("hello world"); 5 | } -------------------------------------------------------------------------------- /CHAPTER 01/harry.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | float celcius = 37, far; 6 | far = (celcius * 9 / 5) + 32; 7 | printf("the value of this celcius temperature in farenheit is %f", far); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /CHAPTER 01/practice.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int length, breadth, area; 5 | area = length * breadth; 6 | 7 | printf("Enter the length of rectangle\n"); 8 | scanf("%d", &length); 9 | printf("Enter the breadth of rectangle\n"); 10 | 11 | scanf("%d", &breadth); 12 | 13 | printf("the area of rectangke is %d\n", area); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /CHAPTER 01/variables.c: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a = 9; 5 | float b = 8.6; 6 | char c = 'u'; 7 | printf("value of a is %d \n ", a); 8 | printf("value of b is %d \n ", b); 9 | printf("value of c is %d \n ", c); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /CHAPTER 02/instructioons.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | // float a=8.9; 6 | // float b=a+9.9; 7 | // printf("the vale of a is %f",b)- 8 | // int a=10,b=8; 9 | // printf("the value of a+b is %d\n",a+b); 10 | // printf("the value of a-b is %d\n",a-b); 11 | // printf("the value of a*b is %d\n",a*b); 12 | printf("the value of 4 to the power 5 is is %f\n", pow(4, 5)); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /CHAPTER 02/practice_set.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | // int num; 6 | // printf("enter the number\n"); 7 | // scanf("%d",&num); 8 | // printf("dividibility test retuurns:%d\n",num%97); 9 | int x = 2, y = 3, z = 3, k = 1; 10 | printf("the evaluation is %d", 3 * x / y - z + k); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /CHAPTER 03/ascii.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char ch; 6 | //97-122=a-z 7 | printf("Enter the value\n"); 8 | scanf("%c", &ch); 9 | if (ch >= 97 && ch <= 122) 10 | { 11 | printf("it is lowercase"); 12 | } 13 | else 14 | { 15 | printf("it is not lowercase");s 16 | 17 | } 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /CHAPTER 03/ascii.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/ascii.exe -------------------------------------------------------------------------------- /CHAPTER 03/ayush.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int age; 6 | int vipPass=1; 7 | printf("enter the number\n"); 8 | scanf("%d", &age); 9 | if ((age <= 18 && age >= 90) || !vipPass == 1) 10 | { 11 | printf("yor are above 18 and below 90, you can drive\n"); 12 | } 13 | else 14 | { 15 | printf("yoy cannot drive"); 16 | } 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /CHAPTER 03/ayush.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/ayush.exe -------------------------------------------------------------------------------- /CHAPTER 03/conditional_operators.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int a; 5 | printf("enter valve\n"); 6 | scanf("%d",&a); 7 | (a<=20)?printf("a is less tham 20"):printf("a is greater tham 20"); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /CHAPTER 03/conditional_operators.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/conditional_operators.exe -------------------------------------------------------------------------------- /CHAPTER 03/if_basic.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int a,b; 5 | printf("enter a number \n"); 6 | scanf("%d",&a); 7 | 8 | if (a>18){ 9 | printf("CAN DRIVE\n",a); 10 | } 11 | else{ 12 | printf("CANNOT DRIVE\n",a); 13 | } 14 | if (a=50){ 15 | printf("HALF CENTURY\n",a); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CHAPTER 03/if_basic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/if_basic.exe -------------------------------------------------------------------------------- /CHAPTER 03/if_else_if.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int num; 6 | printf("your number\n"); 7 | scanf("%d", &num); 8 | if (num == 1) 9 | { 10 | printf("yor number is 1\n"); 11 | } 12 | else if (num == 2) 13 | { 14 | printf("yor number is 2\n"); 15 | } 16 | else if (num == 3) 17 | { 18 | printf("yor number is 3\n"); 19 | } 20 | else if (num == 4) 21 | { 22 | printf("yor number is 4\n"); 23 | } 24 | else 25 | { 26 | printf("yor number is not one two or three or four"); 27 | } 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /CHAPTER 03/if_else_if.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/if_else_if.exe -------------------------------------------------------------------------------- /CHAPTER 03/incometax.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | float tax=0, income; 5 | 6 | printf("Enter your income\n"); 7 | scanf("%f",&income); 8 | 9 | if (income>=250000 && income<=500000) 10 | { 11 | tax=tax+0.05*(income-250000); 12 | } 13 | if (income>=500000 && income<=1000000) 14 | { 15 | tax=tax+0.20*(income-500000); 16 | } 17 | if (income>=1000000 ) 18 | { 19 | tax=tax+0.30*(income-1000000); 20 | } 21 | 22 | printf("your net income tax to be paid is %f\n",tax); 23 | 24 | 25 | 26 | 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /CHAPTER 03/incometax.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/incometax.exe -------------------------------------------------------------------------------- /CHAPTER 03/leap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/leap -------------------------------------------------------------------------------- /CHAPTER 03/leap_year.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int a,b,c,d; 5 | printf("enter the number\n"); 6 | scanf("%d%d%d%d",&a,&b,&c,&d); 7 | 8 | if (a>b && a>c && a>d) 9 | { 10 | printf("the greatest nmber among a,b,c,d is %d\n",a); 11 | } 12 | if (b>a && b>c && b>d) 13 | { 14 | printf("the greatest nmber among a,b,c,d is %d\n",b); 15 | } 16 | if (c>a && c>b && c>d) 17 | { 18 | printf("the greatest nmber among a,b,c,d is %d\n",c); 19 | } 20 | if (d>a && d>b && d>c) 21 | { 22 | printf("the greatest nmber among a,b,c,d is %d\n",d); 23 | } 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /CHAPTER 03/leap_year.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/leap_year.exe -------------------------------------------------------------------------------- /CHAPTER 03/logical_opetaroes.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int age; 5 | printf("enter the number\n"); 6 | scanf("%d",&age); 7 | if(age<=90 && age>=18) 8 | { 9 | printf("you are above 18 and below 90\n"); 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /CHAPTER 03/logical_opetaroes.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/logical_opetaroes.exe -------------------------------------------------------------------------------- /CHAPTER 03/practice.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | float physics, chemistry, maths; 6 | float total; 7 | 8 | printf("enter physics marks\n "); 9 | scanf("%f",&physics); 10 | 11 | printf("enter chemistry marks\n "); 12 | scanf("%f",&chemistry); 13 | 14 | printf("enter maths marks\n "); 15 | scanf("%f",&maths); 16 | 17 | total = (physics + chemistry + maths) / 3; 18 | 19 | if ((total < 40) || physics < 33 || chemistry < 33 || maths < 33) 20 | { 21 | printf("yor total percentage is %f and you are fail\n", total); 22 | } 23 | 24 | else 25 | { 26 | printf("yor total percentage is %f and you are pass\n", total); 27 | } 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /CHAPTER 03/practice.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/practice.exe -------------------------------------------------------------------------------- /CHAPTER 03/printf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/printf -------------------------------------------------------------------------------- /CHAPTER 03/switch_case.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int ratings; 6 | printf("enter your ratings (1-5)\n"); 7 | scanf("%d", &ratings); 8 | switch (ratings) 9 | { 10 | case 1: 11 | printf("yor rating is 1\n"); 12 | break; 13 | case 2: 14 | printf("yor rating is 2\n"); 15 | break; 16 | case 3: 17 | printf("yor rating is 3\n"); 18 | break; 19 | case 4: 20 | printf("yor rating is 4\n"); 21 | break; 22 | case 5: 23 | printf("yor rating is 5\n"); 24 | break; 25 | default: 26 | printf("invalid rating!\n"); 27 | break; 28 | } 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /CHAPTER 03/switch_case.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 03/switch_case.exe -------------------------------------------------------------------------------- /CHAPTER 03/tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | if (a==50){ 2 | printf("HALF CENTURY\n",a); 3 | } -------------------------------------------------------------------------------- /CHAPTER 04/break_statement.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i=0; 6 | do 7 | { 8 | printf("the value of i is %d\n", i); 9 | if (i == 5) 10 | { 11 | break; 12 | } 13 | i++; 14 | } while (i < 10); 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /CHAPTER 04/break_statement.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/break_statement.exe -------------------------------------------------------------------------------- /CHAPTER 04/continue_statement.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n = 5, i = 0; 6 | while (i < 10) 7 | { 8 | i++; 9 | if (i != n) 10 | { 11 | continue; 12 | } 13 | else{ 14 | printf("%d\n",i); 15 | } 16 | } 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /CHAPTER 04/continue_statement.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/continue_statement.exe -------------------------------------------------------------------------------- /CHAPTER 04/dowhile.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int i=0,n; 5 | printf("enter the value\n"); 6 | scanf("%d",&n); 7 | do 8 | { 9 | printf("%d\n",i+1); 10 | i++; 11 | } while (i 2 | 3 | int main(){ 4 | // int n; 5 | // printf("enter the value\n"); 6 | // scanf("%d",&n); 7 | // for (int i=0; i < n; i++) 8 | // { 9 | // printf("the vale of a is %d\n",i+1); 10 | // } 11 | int n; 12 | printf("enter the value\n"); 13 | scanf("%d",&n); 14 | 15 | for (int i=n; i ; i--) 16 | { 17 | printf("the value of i is %d\n",i); 18 | //the loop will run until the value of i becomes 0 19 | } 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /CHAPTER 04/forloop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/forloop.exe -------------------------------------------------------------------------------- /CHAPTER 04/increment_op.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i = 6; 6 | //first print then increment == i++ 7 | //first increment then print == ++i 8 | //first print then decrement == i-- 9 | //first decrement then print == --i 10 | printf("the value of i is %d\n", i++); 11 | printf("the value of i is %d\n", i); 12 | printf("the value of i is %d\n", ++i); 13 | printf("the value of i is %d\n", i); 14 | printf("the value of i is %d\n", i--); 15 | printf("the value of i is %d\n", i); 16 | printf("the value of i is %d\n", --i); 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /CHAPTER 04/increment_op.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/increment_op.exe -------------------------------------------------------------------------------- /CHAPTER 04/practice.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | float a=0; 5 | 6 | 7 | while (a<=20 ) 8 | { 9 | if (a>=10) 10 | { 11 | printf("%f\n",a); 12 | } 13 | 14 | 15 | a++; 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CHAPTER 04/practice.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/practice.exe -------------------------------------------------------------------------------- /CHAPTER 04/practice2.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | int main(){ 4 | int n; 5 | printf("\n\n"); 6 | printf("which table do you want Sir Ayush\n\n"); 7 | scanf("%d",&n); 8 | printf("Here is the table\n\n"); 9 | for (int i =1; i<=10 ; i++) 10 | { 11 | printf("%d X %d = %d\n",n,i,n*i); 12 | } 13 | 14 | 15 | return 0; 16 | } -------------------------------------------------------------------------------- /CHAPTER 04/practice2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/practice2.exe -------------------------------------------------------------------------------- /CHAPTER 04/practice3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i=1, n, sum = 0; 6 | printf("Enter the value\n"); 7 | scanf("%d", &n); 8 | // while ( i <= n ) 9 | // { 10 | // sum += i; 11 | // i++; 12 | // // printf("The sum of values is %d \n", sum); 13 | // } 14 | 15 | do 16 | { 17 | sum *= i; 18 | i++; 19 | } while (i <= n); 20 | 21 | printf("The sum of values from 0 to %d is %d \n",n, sum); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /CHAPTER 04/practice3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/practice3.exe -------------------------------------------------------------------------------- /CHAPTER 04/practice4.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, sum = 0, i; 6 | printf("enter the number\n"); 7 | scanf("%d", &n); 8 | for (i = 0; i <= 10; i++) 9 | { 10 | // printf("the sum is %d\n",i*8); 11 | sum = sum + (i * n); 12 | } 13 | printf("the sum is %d\n", sum); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /CHAPTER 04/practice4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/practice4.exe -------------------------------------------------------------------------------- /CHAPTER 04/practice5.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | 6 | int n, i = 1, fact = 1; 7 | printf("Enter the number\n"); 8 | scanf("%d", &n); 9 | 10 | // program done using for loop 11 | // for (i = 1; i <= n; i++) 12 | // { 13 | // fact = fact * i; 14 | // } 15 | // printf("the value of %d factorial is %d\n", n, fact); 16 | 17 | // program done using while loop 18 | while (i <= n) 19 | { 20 | fact = fact * i; 21 | i++; 22 | } 23 | printf("the value of %d factorial is %d\n", n, fact); 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /CHAPTER 04/practice5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/practice5.exe -------------------------------------------------------------------------------- /CHAPTER 04/practice6.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int n, i, x; 6 | printf("Enter the number\n"); 7 | scanf("%d", &n); 8 | 9 | for (i = 2; i < n-1; i++) 10 | { 11 | if (n%i==0) 12 | 13 | 14 | x=0; 15 | break; 16 | } 17 | 18 | 19 | if (x) 20 | { 21 | printf("%d is a prime number\n", n); 22 | } 23 | else{ 24 | printf("%d is not a prime number\n", n); 25 | } 26 | 27 | 28 | return 0; 29 | } -------------------------------------------------------------------------------- /CHAPTER 04/practice6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/practice6.exe -------------------------------------------------------------------------------- /CHAPTER 04/practiceset.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | int main(){ 4 | printf("MLTIPLICATION TABLE OF 10 ON REVERSE ORDER\n\n"); 5 | for (int i = 10; i ; i--) 6 | { 7 | printf("10 X %d = %d\n",i,10*i); 8 | } 9 | 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /CHAPTER 04/practiceset.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 04/practiceset.exe -------------------------------------------------------------------------------- /CHAPTER 04/tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /CHAPTER 04/whihle loop.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int a; 5 | 6 | scanf("%d",&a); 7 | 8 | 9 | return 0; 10 | } -------------------------------------------------------------------------------- /CHAPTER 05/01.c: -------------------------------------------------------------------------------- 1 | #include 2 | float average(int a, int b, int c); 3 | 4 | int main() 5 | { 6 | int a, b, c; 7 | printf("Enter the vallue of a\n"); 8 | scanf("%d,&a"); 9 | printf("Enter the vallue of b\n"); 10 | scanf("%d,&b"); 11 | printf("Enter the vallue of c\n"); 12 | scanf("%d,&c"); 13 | 14 | printf("The average value is %f\n", average(a, b, c)); 15 | return 0; 16 | } 17 | float average(int a, int b, int c) 18 | { 19 | float result; 20 | 21 | return result = (a + b + c) / 3; 22 | } -------------------------------------------------------------------------------- /CHAPTER 05/01.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/01.exe -------------------------------------------------------------------------------- /CHAPTER 05/02.c: -------------------------------------------------------------------------------- 1 | #include 2 | float average(int a, int b, int c); 3 | 4 | int main() 5 | { 6 | float a, b, c; 7 | 8 | printf("Enter the value of a\n"); 9 | scanf("%f",&a); 10 | printf("Enter the value of b\n"); 11 | scanf("%f",&b); 12 | printf("Enter the value of c\n"); 13 | scanf("%f",&c); 14 | printf("the average value is %f", average(a, b, c)); 15 | return 0; 16 | } 17 | 18 | float average(int a, int b, int c) 19 | { 20 | float result; 21 | result = (float)(a + b + c) / 3; 22 | return result; 23 | } -------------------------------------------------------------------------------- /CHAPTER 05/02.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/02.exe -------------------------------------------------------------------------------- /CHAPTER 05/03.c: -------------------------------------------------------------------------------- 1 | #include 2 | float force(float mass); 3 | int main(){ 4 | float m; 5 | printf("Enter the value of mass in KGs\n"); 6 | scanf("%f",&m); 7 | printf("The vale of force in Newton is %f\n",force(m)); 8 | return 0; 9 | } 10 | float force(float mass){ 11 | float result=mass*9.8; 12 | return result; 13 | } 14 | -------------------------------------------------------------------------------- /CHAPTER 05/03.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/03.exe -------------------------------------------------------------------------------- /CHAPTER 05/change.c: -------------------------------------------------------------------------------- 1 | #include 2 | void change(); 3 | int main() 4 | { 5 | int b = 211; 6 | printf("\nThe value of b before change is %d\n", b); 7 | change(b); 8 | printf("\nThe value of b after change is %d\n", b); 9 | return 0; 10 | } 11 | void change(int b) 12 | { 13 | b = 365; 14 | } -------------------------------------------------------------------------------- /CHAPTER 05/change.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/change.exe -------------------------------------------------------------------------------- /CHAPTER 05/fibonacci.c: -------------------------------------------------------------------------------- 1 | #include 2 | int fib(int); 3 | int main() 4 | { 5 | int n, i, f; 6 | printf("Enter any number\n"); 7 | scanf("%d", &n); 8 | for (i = 0; i < n; i++) 9 | { 10 | f = fib(i); 11 | printf(" %d ", f); 12 | } 13 | 14 | return 0; 15 | } 16 | 17 | int fib(int n) 18 | { 19 | int f; 20 | if (n == 1 || n == 0) 21 | return n; 22 | f = (fib(n - 1) + fib(n - 2)); 23 | return f; 24 | } -------------------------------------------------------------------------------- /CHAPTER 05/fibonacci.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/fibonacci.exe -------------------------------------------------------------------------------- /CHAPTER 05/fnction_inside_fnction.c: -------------------------------------------------------------------------------- 1 | #include 2 | void Good_Morning(); 3 | void Good_Afternoon(); 4 | void Good_Night(); 5 | int main() 6 | { 7 | Good_Morning(); 8 | // Good_Afternoon(); 9 | // Good_Night(); 10 | 11 | return 0; 12 | } 13 | void Good_Morning() 14 | { 15 | printf("Good Morning Ayush\n"); 16 | Good_Afternoon(); 17 | } 18 | void Good_Afternoon() 19 | { 20 | printf("Good Afternoon Ayush\n"); 21 | 22 | Good_Night(); 23 | } 24 | void Good_Night() 25 | { 26 | printf("Good Night Ayush\n"); 27 | } 28 | // void Good_Morning() 29 | // { 30 | // printf("Good Morning Ayush\n"); 31 | // Good_Night(); 32 | // } -------------------------------------------------------------------------------- /CHAPTER 05/fnction_inside_fnction.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/fnction_inside_fnction.exe -------------------------------------------------------------------------------- /CHAPTER 05/function.c: -------------------------------------------------------------------------------- 1 | #include 2 | void display(); //function prototype 3 | int main(){ 4 | int a; 5 | printf("hello\n"); 6 | display(); //function call 7 | printf("Ayush\n"); 8 | printf("Soni\n"); 9 | return 0; 10 | } 11 | void display(){ // function defination 12 | printf("Hii I am display\n"); 13 | } -------------------------------------------------------------------------------- /CHAPTER 05/function.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/function.exe -------------------------------------------------------------------------------- /CHAPTER 05/practice.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/practice.exe -------------------------------------------------------------------------------- /CHAPTER 05/prime_no_using_all_loops.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | void for_loop(); 4 | void while_loop(); 5 | void do_while_loop(); 6 | int main() 7 | { 8 | 9 | //------intializing variables----- 10 | 11 | int n, i , x ; 12 | printf("Enter the value\n"); 13 | scanf("%d", &n); 14 | for_loop(); 15 | // printing wheather the entered number is prime or not 16 | 17 | if (x==0) 18 | { 19 | printf("%d is a prime number\n", n); 20 | } 21 | 22 | else 23 | { 24 | printf("%d is not a prime number\n", n); 25 | } 26 | 27 | return 0; 28 | } 29 | 30 | //Defining all loops as functinn 31 | 32 | void for_loop() 33 | { 34 | // ----- finding prime number usind for loop ------ 35 | int n, i , x ; 36 | for (i = 2; i < n; i++) 37 | { 38 | if (n % i == 0) 39 | { 40 | x = 0; 41 | break; 42 | } 43 | } 44 | } 45 | 46 | void while_loop() 47 | { 48 | 49 | //------ finding prime number usind while loop ------ 50 | int n, i = 2, x = 0; 51 | while (i < n) 52 | { 53 | if (n % i == 0) 54 | { 55 | x = 0; 56 | break; 57 | } 58 | i++; 59 | } 60 | } 61 | void do_while_loop() 62 | { 63 | //----- finding prime number usind do while loop ------ 64 | int n, i = 1, x = 0; 65 | do 66 | { 67 | 68 | if (n % i == 0) 69 | { 70 | x++; 71 | } 72 | i++; 73 | } while (i <= n); 74 | } -------------------------------------------------------------------------------- /CHAPTER 05/prime_no_using_all_loops.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/prime_no_using_all_loops.exe -------------------------------------------------------------------------------- /CHAPTER 05/ptac.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int a=3; 5 | printf("%d %d %d",a,++a,a++); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /CHAPTER 05/ptac.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/ptac.exe -------------------------------------------------------------------------------- /CHAPTER 05/quiz.c: -------------------------------------------------------------------------------- 1 | #include 2 | void Good_Morning(); 3 | void Good_Afternoon(); 4 | void Good_Night(); 5 | int main() 6 | { 7 | Good_Morning(); 8 | Good_Afternoon(); 9 | Good_Night(); 10 | 11 | return 0; 12 | } 13 | // void Good_Morning() 14 | // { 15 | // printf("Good Morning Ayush\n"); 16 | // } 17 | void Good_Afternoon() 18 | { 19 | printf("Good Afternoon Ayush\n"); 20 | } 21 | void Good_Night() 22 | { 23 | printf("Good Night Ayush\n"); 24 | } 25 | void Good_Morning() 26 | { 27 | printf("Good Morning Ayush\n"); 28 | } -------------------------------------------------------------------------------- /CHAPTER 05/quiz.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/quiz.exe -------------------------------------------------------------------------------- /CHAPTER 05/quiz2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | int side; 6 | printf("Enter the value of side\n"); 7 | scanf("%d",&side); 8 | printf("The area of side %d is %f",side,pow(side,2)); 9 | 10 | 11 | return 0; 12 | } -------------------------------------------------------------------------------- /CHAPTER 05/quiz2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/quiz2.exe -------------------------------------------------------------------------------- /CHAPTER 05/recursion.c: -------------------------------------------------------------------------------- 1 | #include 2 | int factorial(int x); 3 | int main() 4 | { 5 | int a = 5; 6 | printf("The value of %d factorial is %d", a, factorial(a)); 7 | return 0; 8 | } 9 | 10 | int factorial(int x) 11 | { 12 | if (x == 1 || x == 0) 13 | { 14 | return 1; 15 | } 16 | else 17 | { 18 | return x * factorial(x - 1); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /CHAPTER 05/recursion.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/recursion.exe -------------------------------------------------------------------------------- /CHAPTER 05/sum_function.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sum(int a, int b); 4 | int main() 5 | { 6 | int c; 7 | c = sum(2, 5); 8 | printf("\nThe value of sum is %d\n",c); 9 | return 0; 10 | } 11 | 12 | int sum(int a, int b) 13 | { 14 | int result; 15 | result = a + b; 16 | return result; 17 | } -------------------------------------------------------------------------------- /CHAPTER 05/sum_function.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 05/sum_function.exe -------------------------------------------------------------------------------- /CHAPTER 05/tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | int a, b, c; 2 | printf("Enter the vallue of a\n"); 3 | scanf("%d,&a"); 4 | printf("Enter the vallue of b\n"); 5 | scanf("%d,&b"); 6 | printf("Enter the vallue of c\n"); 7 | scanf("%d,&c"); -------------------------------------------------------------------------------- /CHAPTER 06/call_by_reference.c: -------------------------------------------------------------------------------- 1 | #include 2 | void swap(int *a, int *b); 3 | void wrong_swap(int a, int b); 4 | int main() 5 | { 6 | int a = 3, b = 8; 7 | printf("The value of a and b before swap is %d and %d\n", a, b); 8 | // wrong_swap(a, b); // will not work because it is call by value 9 | swap(&a, &b); // will work because it is call by referece 10 | printf("The value of a and b after swap is %d and %d\n", a, b); 11 | 12 | return 0; 13 | } 14 | void wrong_swap(int a, int b) 15 | { 16 | int temp; 17 | temp = a; 18 | a = b; 19 | b = temp; 20 | } 21 | void swap(int *a, int *b) 22 | { 23 | int temp; 24 | temp = *a; 25 | * a = *b; 26 | * b = temp; 27 | } 28 | -------------------------------------------------------------------------------- /CHAPTER 06/call_by_reference.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/call_by_reference.exe -------------------------------------------------------------------------------- /CHAPTER 06/call_by_value.c: -------------------------------------------------------------------------------- 1 | #include 2 | int sum(int a, int b); 3 | int main() 4 | { 5 | int a = 4, b = 7; 6 | printf("the value of a and b is %d and %d\n", a, b); 7 | 8 | printf("the value of 4+7 is %d\n", sum(6, 12)); 9 | printf("the value of a and b after function call is %d and %d\n", a, b); 10 | 11 | return 0; 12 | } 13 | int sum(int a, int b) 14 | { 15 | int c; 16 | c=a+b; 17 | b=65165; 18 | a=6565; 19 | return c; 20 | } -------------------------------------------------------------------------------- /CHAPTER 06/call_by_value.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/call_by_value.exe -------------------------------------------------------------------------------- /CHAPTER 06/pointers.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int i = 72; 6 | int *j = &i; //j will now store the addresss of i 7 | int **k = &j; //k will now store the address of j 8 | printf("The value of i is %d\n", i); 9 | printf("The value of i is %d\n", *j); 10 | printf("The value of i is %u\n", &i); 11 | printf("The value of i is %u\n", j); 12 | printf("The value of j is %u\n", &j); 13 | printf("The value of j is %u\n", *(&j)); 14 | printf("The value of k is %u\n",&k); 15 | printf("The value of j is %u\n",k); 16 | 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /CHAPTER 06/pointers.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/pointers.exe -------------------------------------------------------------------------------- /CHAPTER 06/practice_1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int b=6; 5 | int *ptr; 6 | ptr=&b; 7 | printf(" the value of b is %u\n", *ptr); 8 | printf(" the address of a is %u\n", ptr); 9 | 10 | return 0; 11 | } -------------------------------------------------------------------------------- /CHAPTER 06/practice_1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/practice_1.exe -------------------------------------------------------------------------------- /CHAPTER 06/practice_2.c: -------------------------------------------------------------------------------- 1 | #include 2 | void printAdd(int a) 3 | { 4 | printf(" The address of a is %u\n", &a); 5 | } 6 | int main() 7 | { 8 | int i = 6; 9 | printf(" The value of i is %d\n", i); 10 | printAdd(i); 11 | printf(" The address of i is %u\n", &i); 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /CHAPTER 06/practice_2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/practice_2.exe -------------------------------------------------------------------------------- /CHAPTER 06/practice_3.c: -------------------------------------------------------------------------------- 1 | #include 2 | void inc(int a) 3 | { 4 | a = a * 10; 5 | } 6 | 7 | int main() 8 | { 9 | int x; 10 | printf("enter the value\n"); 11 | scanf("%d", &x); 12 | printf("The value of x before increment is %d \n", x); 13 | inc(x); 14 | printf("The value of x after increment is %d \n", x); 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /CHAPTER 06/practice_3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/practice_3.exe -------------------------------------------------------------------------------- /CHAPTER 06/practice_4.c: -------------------------------------------------------------------------------- 1 | #include 2 | void Sum_and_Avg(int a, int b,int *sum,float *avg) 3 | { 4 | *sum = a + b; 5 | *avg =(float) *sum / 2; 6 | } 7 | int main() 8 | { 9 | int i, j, sum; 10 | float avg; 11 | i=3; 12 | j=6; 13 | Sum_and_Avg(i, j, &sum, &avg); 14 | printf("The value of sum is %d\n",sum); 15 | printf("The value of average is %f\n",avg); 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CHAPTER 06/practice_4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/practice_4.exe -------------------------------------------------------------------------------- /CHAPTER 06/practice_6.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/practice_6.c -------------------------------------------------------------------------------- /CHAPTER 06/ptactice_5.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int i=654; 5 | int *ptr; 6 | int **ptr_ptr; 7 | ptr=&i; 8 | ptr_ptr=&ptr; 9 | printf("thr value of i id %d",**ptr_ptr); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /CHAPTER 06/ptactice_5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 06/ptactice_5.exe -------------------------------------------------------------------------------- /CHAPTER 07/2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int arr[3][2]; 6 | for (int i = 0; i < 3; i++) 7 | { 8 | for (int j = 0; j < 2; j++) 9 | { 10 | scanf(" %d\n", &arr[i][j]); 11 | } 12 | } 13 | 14 | for (int i = 0; i < 3; i++) 15 | { 16 | for (int j = 0; j < 2; j++) 17 | { 18 | printf(" %d\n", arr[i][j]); 19 | } 20 | printf("\n"); 21 | } 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /CHAPTER 07/2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/2.exe -------------------------------------------------------------------------------- /CHAPTER 07/2D_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int n_students =3; 5 | int n_subjects =5; 6 | int marks[3][5]; 7 | for(int i=0;i 2 | 3 | int main() 4 | { 5 | int arr[2][2][4]; 6 | for (int i = 0; i < 2; i++) 7 | { 8 | for (int j = 0; j < 3; j++) 9 | { 10 | for (int k = 0; k < 4; k++) 11 | { 12 | printf("The addredd of arr[%d][%d][%d] is %u \n", i, j, k, &arr[i][j][k]); 13 | } 14 | } 15 | } 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CHAPTER 07/3_dimensional_array.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/3_dimensional_array.exe -------------------------------------------------------------------------------- /CHAPTER 07/array.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int marks[4]; 5 | marks[0]=21; 6 | marks[1]=20; 7 | marks[2]=30; 8 | marks[3]=50; 9 | printf("%d",marks[0]); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /CHAPTER 07/array.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/array.exe -------------------------------------------------------------------------------- /CHAPTER 07/array_initiLIZE.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | // int a[]={34,222,67,652,62684,6954,9684,16841,684,164,16,16,163,16,1,6341,164,894,19,841,616}; 5 | // printf("the value of a[0] is %d\n",a[0]); 6 | // printf("the value of a[1] is %d\n",a[1]); 7 | // printf("the value of a[2] is %d\n",a[2]); 8 | // printf("the value of a[10] is %d\n",a[10]); 9 | // printf("the value of a[20] is %d\n",a[20]); 10 | int arr[3]={1,2,3,6}; 11 | printf("%u\n",&arr[0]); 12 | printf("%u\n",&arr[1]); 13 | printf("%u\n",&arr[2]); 14 | printf("%u\n",&arr[3]); 15 | // printf("%u",&arr[0]); 16 | 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CHAPTER 07/array_initiLIZE.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/array_initiLIZE.exe -------------------------------------------------------------------------------- /CHAPTER 07/array_inputs.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int marks[4]; 6 | printf("Enter thr value for marks for student 1 : "); 7 | scanf("%d", &marks[0]); 8 | printf("Enter thr value for marks for student 2 : "); 9 | scanf("%d", &marks[1]); 10 | printf("Enter thr value for marks for student 3 : "); 11 | scanf("%d", &marks[2]); 12 | printf("Enter thr value for marks for student 3 : "); 13 | scanf("%d", &marks[3]); 14 | 15 | printf("You have entered %d %d %d and %d",marks[0],marks[1],marks[2],marks[3]); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /CHAPTER 07/array_inputs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/array_inputs.exe -------------------------------------------------------------------------------- /CHAPTER 07/array_inputs_using_loops.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int marks[5]; 6 | for (int i = 0; i < 5; i++) 7 | { 8 | printf("Enter the value of marks for student %d : ", i+1); 9 | scanf("%d",&marks[i]); 10 | } 11 | for (int i = 0; i < 5; i++) 12 | { 13 | printf("The value of marks for student %d is %d: \n", i+1,marks[i]); 14 | 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /CHAPTER 07/array_inputs_using_loops.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/array_inputs_using_loops.exe -------------------------------------------------------------------------------- /CHAPTER 07/pointer_arethimatic.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | // int i=20; 5 | // int *ptr=&i; 6 | // printf("The value of ptr is %u\n",ptr); 7 | // // ptr++; 8 | // ptr=ptr+4; 9 | // printf("The value of ptr is %u\n",ptr); 10 | char c=34; 11 | char *ptr= &c; 12 | printf("The value of ptr is %u\n",ptr); 13 | ptr++; 14 | printf("The value of ptr is %u\n",ptr); 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /CHAPTER 07/pointer_arethimatic.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/pointer_arethimatic.exe -------------------------------------------------------------------------------- /CHAPTER 07/practice.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int arr[10]; 6 | int *ptr = &arr[0]; 7 | ptr = ptr + 2; 8 | if (ptr == &arr[2]) 9 | { 10 | printf("These point at the samae location in memory\n"); 11 | } 12 | else 13 | { 14 | printf("These do not point at the samae location in memory\n"); 15 | } 16 | printf(""); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CHAPTER 07/practice.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/practice.exe -------------------------------------------------------------------------------- /CHAPTER 07/practice2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | int mul[10]; 6 | for (int i = 0; i < 10; i++) 7 | { 8 | mul[i] = 5 * (i + 1); 9 | } 10 | for (int i = 0; i < 10; i++) 11 | { 12 | printf("5x%d=%d\n",i+1,mul[i]); 13 | } 14 | 15 | 16 | return 0; 17 | } -------------------------------------------------------------------------------- /CHAPTER 07/practice2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/practice2.exe -------------------------------------------------------------------------------- /CHAPTER 07/quiz.c: -------------------------------------------------------------------------------- 1 | // #include 2 | 3 | // int main(){ 4 | // // int a; 5 | // // int *j=&a; 6 | // // // printf("the value of j is %u\n",j); 7 | // // // j++; 8 | // // // printf("the value of j is %u\n",j); 9 | // // int a; 10 | // // int *j=&a; 11 | // // printf("the value of j is %u\n",j); 12 | // // j--; 13 | // // printf("the value of j is %u\n",j); 14 | // int a; 15 | // int *j=&a; 16 | // printf("the value of j is %u\n",j); 17 | // j--; 18 | // printf("the value of j is %u\n",j); 19 | // printf("the value of j is %u\n",j-j); 20 | 21 | 22 | 23 | 24 | 25 | // return 0; 26 | // } 27 | #include 28 | 29 | // Driver Code 30 | int main() 31 | { 32 | // Integer variable 33 | int N = 4; 34 | 35 | // Pointer to an integer 36 | int *ptr1, *ptr2; 37 | 38 | // Pointer stores 39 | // the address of N 40 | ptr1 = &N; 41 | ptr2 = &N; 42 | 43 | printf("Pointer ptr1 " 44 | "before Increment: "); 45 | printf("%p \n", ptr1); 46 | 47 | // Incrementing pointer ptr1; 48 | ptr1++; 49 | 50 | printf("Pointer ptr1 after" 51 | " Increment: "); 52 | printf("%p \n\n", ptr1); 53 | 54 | printf("Pointer ptr1 before" 55 | " Decrement: "); 56 | printf("%p \n", ptr1); 57 | 58 | // Decrementing pointer ptr1; 59 | ptr1--; 60 | 61 | printf("Pointer ptr1 after" 62 | " Decrement: "); 63 | printf("%p \n\n", ptr1); 64 | 65 | return 0; 66 | } -------------------------------------------------------------------------------- /CHAPTER 07/quiz.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/quiz.exe -------------------------------------------------------------------------------- /CHAPTER 07/quiz2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int *p, *q; 5 | 6 | p = (int *) 1000; 7 | q = (int *) 2000; 8 | 9 | printf("%d", q - p); 10 | 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /CHAPTER 07/quiz2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/quiz2.exe -------------------------------------------------------------------------------- /CHAPTER 07/quiz3.c: -------------------------------------------------------------------------------- 1 | #include 2 | void display(int a[4][5]) 3 | { 4 | printf("The 2 dimensional array is:%d\n", a[4][5]); 5 | } 6 | int main() 7 | { 8 | int i[4][5]; 9 | printf("Enter the values\n"); 10 | scanf("%d", &i[4][5]); 11 | display(i[4][5]); 12 | // printf("The 2 dimensional array is:%d\n", i[4][5]); 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /CHAPTER 07/quiz3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/quiz3.exe -------------------------------------------------------------------------------- /CHAPTER 07/reverse_array.c: -------------------------------------------------------------------------------- 1 | #include 2 | void reverse(int *arr, int n) 3 | { 4 | int temp; 5 | for (int i = 0; i < n / 2; i++) 6 | { 7 | temp = arr[i]; 8 | arr[i] = arr[n - i - 1]; 9 | arr[n - i - 1] = temp; 10 | } 11 | } 12 | int main() 13 | { 14 | int arr[] = {1, 2, 3, 4, 5, 6, 7, 8}; 15 | reverse(arr, 8); 16 | for (int i = 0; i < 8; i++) 17 | { 18 | printf("The value of %d elemet is %d\n", i+1, arr[i]); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /CHAPTER 07/reverse_array.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/reverse_array.exe -------------------------------------------------------------------------------- /CHAPTER 07/table.c: -------------------------------------------------------------------------------- 1 | #include 2 | void printTable(int *mulTable, int num, int n) 3 | { 4 | printf("The multiplication table of %d is :\n", num); 5 | for (int i = 0; i < n; i++) 6 | { 7 | mulTable[i] = num * (i + 1); 8 | } 9 | for (int i = 0; i < n; i++) 10 | { 11 | printf(" %d x %d = %d \n", num, i + 1, mulTable[i]); 12 | } 13 | printf("\n**************************************************\n"); 14 | } 15 | int main() 16 | { 17 | 18 | int mulTable[3][10]; 19 | printTable(mulTable[0], 2, 10); 20 | printTable(mulTable[1], 7, 10); 21 | printTable(mulTable[2], 9, 10); 22 | 23 | return 0; 24 | } -------------------------------------------------------------------------------- /CHAPTER 07/table.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 07/table.exe -------------------------------------------------------------------------------- /CHAPTER 07/tempCodeRunnerFile.c: -------------------------------------------------------------------------------- 1 | 2 | { -------------------------------------------------------------------------------- /CHAPTER 08/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "string.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /CHAPTER 08/convienentway_toprint_string.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | char *s="24K Goldn - Mood"; 5 | printf("%s",s); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /CHAPTER 08/convienentway_toprint_string.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/convienentway_toprint_string.exe -------------------------------------------------------------------------------- /CHAPTER 08/dif_bet_2_int_meth0ods.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char *ptr="Ayush"; 6 | // char ptr[] = "Ayush Lalchand Soni"; 7 | ptr= "huzefa bhai"; 8 | printf("%s", ptr); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /CHAPTER 08/dif_bet_2_int_meth0ods.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/dif_bet_2_int_meth0ods.exe -------------------------------------------------------------------------------- /CHAPTER 08/gets_puts.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | char s[4]; 5 | printf("Enter your name\n"); 6 | gets(s); 7 | printf("Your name is %s",s); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /CHAPTER 08/gets_puts.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/gets_puts.exe -------------------------------------------------------------------------------- /CHAPTER 08/inputting_strings.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | char s[4]; 5 | printf("Enter your name\n"); 6 | scanf("%s",s); 7 | printf("Your name is %s",s); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /CHAPTER 08/inputting_strings.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/inputting_strings.exe -------------------------------------------------------------------------------- /CHAPTER 08/practice1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | char a[24]; 7 | char b[24]; 8 | char c; 9 | int i = 0; 10 | printf("The value of first string\n"); 11 | scanf("%s", a); 12 | printf("The value of second string character by character\n"); 13 | 14 | // fflush(stdin); 15 | // scanf("%c", &c); 16 | while (c != '\n') 17 | { 18 | fflush(stdin); 19 | scanf("%c", &c); 20 | 21 | b[i] = c; 22 | i++; 23 | } 24 | b[i-1] = '\0'; 25 | printf("The value of a is %s \n", a); 26 | printf("The value of b is %s \n", b); 27 | printf("strcmp for these strings is %d", strcmp(a, b)); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /CHAPTER 08/practice1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/practice1.exe -------------------------------------------------------------------------------- /CHAPTER 08/practice2.c: -------------------------------------------------------------------------------- 1 | #include 2 | // #include 3 | int strlen(char *a){ 4 | char *ptr=a; 5 | int len=0; 6 | while (*ptr!='\0') 7 | { 8 | len++; 9 | ptr++; 10 | } 11 | return len; 12 | } 13 | 14 | int main(){ 15 | char a[]="AyushsbvskjvhjskvbkJVBJ"; 16 | int b=strlen(a); 17 | printf("The length of this string is %d",b); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /CHAPTER 08/practice2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/practice2.exe -------------------------------------------------------------------------------- /CHAPTER 08/practice3.c: -------------------------------------------------------------------------------- 1 | #include 2 | void slice(char *a, int m, int n) 3 | { 4 | int i = 0; 5 | while ((m + i) < n) 6 | { 7 | a[i] = a[i + m]; 8 | i++; 9 | } 10 | a[i] = '\0'; 11 | } 12 | int main() 13 | { 14 | char a[] = "YASHODA TECHNICAL CAMPUS"; 15 | slice(a, 1, 8); 16 | printf("%s", a); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /CHAPTER 08/practice3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/practice3.exe -------------------------------------------------------------------------------- /CHAPTER 08/practice4.c: -------------------------------------------------------------------------------- 1 | #include 2 | void dencrypt(char*a){ 3 | char *ptr=a; 4 | while (*ptr!='\0') 5 | { 6 | *ptr=*ptr+2; 7 | ptr++; 8 | } 9 | 10 | 11 | } 12 | int main(){ 13 | 14 | char a[1000]; 15 | //="c{wuj"; 16 | scanf("%s",a); 17 | dencrypt(a); 18 | printf("%s",a); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /CHAPTER 08/practice4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/practice4.exe -------------------------------------------------------------------------------- /CHAPTER 08/practice5.c: -------------------------------------------------------------------------------- 1 | #include 2 | int occurence(char st[], char c) 3 | { 4 | char *ptr =st ; 5 | int count = 0; 6 | while (*ptr != '\0') 7 | { 8 | if (*ptr == c) 9 | { 10 | count++; 11 | } 12 | ptr++; 13 | } 14 | return count; 15 | } 16 | int main() 17 | { 18 | char st[] = "aigbfvaidfgbvi"; 19 | int count = occurence(st, 'i'); 20 | printf("Occurence = %d", count); 21 | return 0; 22 | } -------------------------------------------------------------------------------- /CHAPTER 08/practice5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/practice5.exe -------------------------------------------------------------------------------- /CHAPTER 08/practice6.c: -------------------------------------------------------------------------------- 1 | #include 2 | int occurence(char st[], char c) 3 | { 4 | char *ptr =st ; 5 | int count = 0; 6 | while (*ptr != '\0') 7 | { 8 | if (*ptr == c) 9 | { 10 | count++; 11 | printf("%c is present in the string\n",c); 12 | // count++; 13 | } 14 | // printf("%c is present in the string\n",c); 15 | // else{ 16 | // printf("%c is not present\n",c); 17 | // } 18 | ptr++; 19 | 20 | } 21 | return count; 22 | } 23 | int main() 24 | { 25 | char st[] = "ayush"; 26 | int count = occurence(st, 'i'); 27 | // printf( "%c is present in string", count); 28 | return 0; 29 | } -------------------------------------------------------------------------------- /CHAPTER 08/practice6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/practice6.exe -------------------------------------------------------------------------------- /CHAPTER 08/strcat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | char a[45]= "Ayush "; 6 | char *b="Soni"; 7 | strcat(a,b); 8 | printf("%s",a); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /CHAPTER 08/strcat.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/strcat.exe -------------------------------------------------------------------------------- /CHAPTER 08/strcmp.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | char *a="Ayus"; 6 | char a2[45]="Ayush"; 7 | int val= strcmp(a2,a); 8 | printf("Now the val is %d",val); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /CHAPTER 08/strcmp.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/strcmp.exe -------------------------------------------------------------------------------- /CHAPTER 08/strcpy.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | char *a="Ayush"; 6 | char a2[45]; 7 | strcpy(a2,a); 8 | printf("Soni %s",a2); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /CHAPTER 08/strcpy.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/strcpy.exe -------------------------------------------------------------------------------- /CHAPTER 08/string.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | // char s[]={'A','y','u','s','h','\0'}; 6 | char str[] = "Ayush"; 7 | char *ptr = str; 8 | while (*ptr != '\0') 9 | { 10 | printf("%c", *ptr); 11 | ptr++; 12 | } 13 | 14 | return 0; 15 | } -------------------------------------------------------------------------------- /CHAPTER 08/string.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/string.exe -------------------------------------------------------------------------------- /CHAPTER 08/stringusingptr.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | // char *ptr="Ayush"; 5 | char ptr[]="Ayush Lalchand Soni"; 6 | printf("%s",ptr); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /CHAPTER 08/stringusingptr.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/stringusingptr.exe -------------------------------------------------------------------------------- /CHAPTER 08/strlen.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | 6 | //strlen()=counts the no. of charters in c 7 | 8 | char *ptr="Ayush Soni"; 9 | int a = strlen(ptr); 10 | printf("the length of string ptr is %d",a); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /CHAPTER 08/strlen.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 08/strlen.exe -------------------------------------------------------------------------------- /CHAPTER 09/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdio.h": "c" 4 | } 5 | } -------------------------------------------------------------------------------- /CHAPTER 09/another_way_to_inistrct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct employee 4 | { 5 | int code; 6 | float salary; 7 | char name[10]; 8 | }; 9 | 10 | int main(){ 11 | struct employee Zydus ={100,10.35,"Ayush"}; 12 | printf("Code is %d\n",Zydus.code); 13 | printf("Salary is %f\n",Zydus.salary); 14 | printf("Name is %s\n",Zydus.name); 15 | 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /CHAPTER 09/another_way_to_inistrct.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/another_way_to_inistrct.exe -------------------------------------------------------------------------------- /CHAPTER 09/array_of_structure.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct employee 4 | { 5 | int code; 6 | float salary; 7 | char name[10]; 8 | }; 9 | 10 | int main(){ 11 | struct employee facebook[100]; 12 | 13 | facebook[0].code=100; 14 | facebook[0].salary=100.45; 15 | strcpy(facebook[0].name, "Ayush"); 16 | 17 | facebook[1].code=101; 18 | facebook[1].salary=106.55; 19 | strcpy(facebook[1].name, "Huzefa"); 20 | 21 | facebook[2].code=102; 22 | facebook[2].salary=90.65; 23 | strcpy(facebook[2].name, "Zydus"); 24 | 25 | printf("done"); 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /CHAPTER 09/array_of_structure.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/array_of_structure.exe -------------------------------------------------------------------------------- /CHAPTER 09/function_to_struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct employee 4 | { 5 | int code; 6 | char name[10]; 7 | float salary; 8 | }; 9 | 10 | void show(struct employee emp) 11 | { 12 | printf("The code of employee is %d\n", emp.code); 13 | printf("The salary of employee is %f\n", emp.salary); 14 | printf("The name of employee is %s\n", emp.name); 15 | } 16 | int main() 17 | { 18 | struct employee e1; 19 | struct employee *ptr; 20 | 21 | ptr = &e1; 22 | // (*ptr).code=101; 23 | ptr->code = 101; 24 | ptr->salary = 96.45; 25 | strcpy(ptr->name, "Ayush"); 26 | show(e1); 27 | // printf("%d",e1.code); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /CHAPTER 09/function_to_struct.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/function_to_struct.exe -------------------------------------------------------------------------------- /CHAPTER 09/pointer_to_struct.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct employee 4 | { 5 | int code; 6 | char name[10]; 7 | float salary; 8 | }; 9 | int main() 10 | { 11 | struct employee e1 ; 12 | struct employee *ptr; 13 | 14 | ptr= &e1; 15 | // (*ptr).code=101; 16 | ptr->code=101; 17 | printf("%d",e1.code); 18 | 19 | 20 | return 0; 21 | } -------------------------------------------------------------------------------- /CHAPTER 09/pointer_to_struct.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/pointer_to_struct.exe -------------------------------------------------------------------------------- /CHAPTER 09/prac1.c: -------------------------------------------------------------------------------- 1 | #include 2 | typedef struct vector 3 | { 4 | int x; 5 | int y; 6 | }sum1; 7 | 8 | 9 | int main(){ 10 | struct vector v1,v2; 11 | v1.x=26; 12 | v1.y=29; 13 | printf("X dimension is %d and Y dimension is %d\n",v1.x,v1.y); 14 | 15 | v2.x=36; 16 | v2.y=16; 17 | printf("X dimension is %d and Y dimension is %d\n",v2.x,v2.y); 18 | 19 | 20 | 21 | return 0; 22 | 23 | } -------------------------------------------------------------------------------- /CHAPTER 09/prac1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/prac1.exe -------------------------------------------------------------------------------- /CHAPTER 09/prac2.c: -------------------------------------------------------------------------------- 1 | #include 2 | typedef struct vector 3 | { 4 | int x; 5 | int y; 6 | }sum1; 7 | sum1 sumvector(sum1 v1,sum1 v2) 8 | { 9 | sum1 result; 10 | result.x=v1.x+v2.x; 11 | result.y=v1.y+v2.y; 12 | return result; 13 | }; 14 | 15 | int main(){ 16 | struct vector v1,v2,sum; 17 | 18 | v1.x=26; 19 | v1.y=29; 20 | printf("X dimension is %d and Y dimension is %d\n",v1.x,v1.y); 21 | 22 | v2.x=36; 23 | v2.y=16; 24 | printf("X dimension is %d and Y dimension is %d\n",v2.x,v2.y); 25 | 26 | sum = sumvector(v1,v2); 27 | printf("X dimension of result is %d and Y dimension of result is %d\n",sum.x,sum.y); 28 | 29 | return 0; 30 | 31 | } -------------------------------------------------------------------------------- /CHAPTER 09/prac3.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/prac3.c -------------------------------------------------------------------------------- /CHAPTER 09/prac4.c: -------------------------------------------------------------------------------- 1 | #include 2 | typedef struct complex 3 | { 4 | int real; 5 | int imaginary; 6 | }comp; 7 | void display(comp c){ 8 | printf("The real part is %d \n",c.real); 9 | printf("The imaginary part is %d \n",c.imaginary); 10 | 11 | } 12 | int main(){ 13 | comp cnums[5]; 14 | for (int i = 0; i <5; i++) 15 | { 16 | printf("Enter the real value for %d num\n",i+1); 17 | scanf("%d",&cnums[i].real); 18 | printf("Enter the imaginary value for %d num\n",i+1); 19 | scanf("%d",&cnums[i].imaginary); 20 | } 21 | for (int i = 0; i <5; i++) 22 | display(cnums[i]); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /CHAPTER 09/prac4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/prac4.exe -------------------------------------------------------------------------------- /CHAPTER 09/prac5.c: -------------------------------------------------------------------------------- 1 | #include 2 | struct bankaccount 3 | { 4 | int accnum; 5 | int connum; 6 | char name; 7 | 8 | }; 9 | 10 | int main(){ 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /CHAPTER 09/prac6.c: -------------------------------------------------------------------------------- 1 | #include 2 | typedef struct date 3 | { 4 | int date; 5 | int month; 6 | int year; 7 | } date; 8 | 9 | void display(date d) 10 | { 11 | printf("The date is %d/%d/%d\n", d.date, d.month, d.year); 12 | } 13 | int datecmp(date d1, date d2) 14 | { 15 | if (d1.year > d2.year) 16 | { 17 | return 1; 18 | } 19 | if (d1.year < d2.year) 20 | { 21 | return -1; 22 | } 23 | if (d1.month > d2.month) 24 | { 25 | return 1; 26 | } 27 | if (d1.month < d2.month) 28 | { 29 | return -1; 30 | } 31 | if (d1.date > d2.date) 32 | { 33 | return 1; 34 | } 35 | if (d1.date < d2.date) 36 | { 37 | return -1; 38 | } 39 | else 40 | return 0; 41 | } 42 | int main() 43 | { 44 | date d1 = {2, 4, 2021}; 45 | date d2 = {2, 4, 2021}; 46 | display(d1); 47 | display(d2); 48 | int a=datecmp(d1,d2); 49 | printf("Date comparision function returns : %d\n",a); 50 | return 0; 51 | } -------------------------------------------------------------------------------- /CHAPTER 09/prac6.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/prac6.exe -------------------------------------------------------------------------------- /CHAPTER 09/prac7.c: -------------------------------------------------------------------------------- 1 | #include 2 | typedef struct time 3 | { 4 | int hours; 5 | int minute; 6 | int seconds; 7 | } time; 8 | 9 | void display(time t) 10 | { 11 | printf("The time is %d : %d : %d\n", t.hours, t.minute, t.seconds); 12 | } 13 | int timecmp(time t1, time t2) 14 | { 15 | if (t1.hours > t2.hours) 16 | { 17 | return 1; 18 | } 19 | if (t1.hours < t2.hours) 20 | { 21 | return -1; 22 | } 23 | if (t1.minute > t2.minute) 24 | { 25 | return 1; 26 | } 27 | if (t1.minute < t2.minute) 28 | { 29 | return -1; 30 | } 31 | if (t1.seconds > t2.seconds) 32 | { 33 | return 1; 34 | } 35 | if (t1.seconds < t2.seconds) 36 | { 37 | return -1; 38 | } 39 | else 40 | return 0; 41 | } 42 | int main() 43 | { 44 | time t1 = {10, 40, 21}; 45 | time t2 = {2, 4, 20}; 46 | display(t1); 47 | display(t2); 48 | int a=timecmp(t1,t2); 49 | printf("Time comparision function returns : %d\n",a); 50 | return 0; 51 | } -------------------------------------------------------------------------------- /CHAPTER 09/prac7.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/prac7.exe -------------------------------------------------------------------------------- /CHAPTER 09/special_ques.c: -------------------------------------------------------------------------------- 1 | #include 2 | typedef struct timestamp 3 | { 4 | int date; 5 | int month; 6 | int year; 7 | int hours; 8 | int minute; 9 | int seconds; 10 | } timestamp; 11 | 12 | void display(timestamp ts) 13 | { 14 | printf("The timestamp is %d / %d / %d %d : %d : %d\n",ts.date, ts.month, ts.year, ts.hours, ts.minute, ts.seconds); 15 | } 16 | int timestampcmp(timestamp ts1, timestamp ts2) 17 | { 18 | if (ts1.year > ts2.year) 19 | { 20 | return 1; 21 | } 22 | if (ts1.year < ts2.year) 23 | { 24 | return -1; 25 | } 26 | if (ts1.month > ts2.month) 27 | { 28 | return 1; 29 | } 30 | if (ts1.month < ts2.month) 31 | { 32 | return -1; 33 | } 34 | if (ts1.date > ts2.date) 35 | { 36 | return 1; 37 | } 38 | if (ts1.date < ts2.date) 39 | { 40 | return -1; 41 | } 42 | if (ts1.hours > ts2.hours) 43 | { 44 | return 1; 45 | } 46 | if (ts1.hours < ts2.hours) 47 | { 48 | return -1; 49 | } 50 | if (ts1.minute > ts2.minute) 51 | { 52 | return 1; 53 | } 54 | if (ts1.minute < ts2.minute) 55 | { 56 | return -1; 57 | } 58 | if (ts1.seconds > ts2.seconds) 59 | { 60 | return 1; 61 | } 62 | if (ts1.seconds < ts2.seconds) 63 | { 64 | return -1; 65 | } 66 | 67 | else 68 | return 0; 69 | } 70 | int main() 71 | { 72 | timestamp ts1 = {2, 4, 2021, 10, 40, 21}; 73 | timestamp ts2 = {4, 7, 2024, 2, 4, 20}; 74 | display(ts1); 75 | display(ts2); 76 | int a=timestampcmp(ts1,ts2); 77 | printf("timestamp comparision function returns : %d\n",a); 78 | return 0; 79 | } -------------------------------------------------------------------------------- /CHAPTER 09/special_ques.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/special_ques.exe -------------------------------------------------------------------------------- /CHAPTER 09/strct_input.c: -------------------------------------------------------------------------------- 1 | #include 2 | struct employee 3 | { 4 | int code; 5 | char name[10]; 6 | float salary; 7 | }; 8 | int main() 9 | { 10 | struct employee e1, e2, e3; 11 | 12 | return 0; 13 | } -------------------------------------------------------------------------------- /CHAPTER 09/structures.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | struct employee 4 | { 5 | int code; 6 | char name[10]; 7 | float salary; 8 | }; 9 | 10 | int main(){ 11 | 12 | struct employee e1; 13 | e1.code=100; 14 | e1.salary=64.64; 15 | strcpy(e1.name, "Ayush"); 16 | printf("%d",e1.code); 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /CHAPTER 09/structures.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/structures.exe -------------------------------------------------------------------------------- /CHAPTER 09/typedef.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | typedef struct employee 4 | { 5 | int code; 6 | char name[10]; 7 | float salary; 8 | }zydus; 9 | 10 | void show(struct employee emp) 11 | { 12 | printf("The code of employee is %d\n", emp.code); 13 | printf("The salary of employee is %f\n", emp.salary); 14 | printf("The name of employee is %s\n", emp.name); 15 | } 16 | int main() 17 | { 18 | zydus e1; 19 | zydus *ptr; 20 | 21 | ptr = &e1; 22 | // (*ptr).code=101; 23 | ptr->code = 101; 24 | ptr->salary = 96.45; 25 | strcpy(ptr->name, "Ayush"); 26 | show(e1); 27 | // printf("%d",e1.code); 28 | 29 | return 0; 30 | } -------------------------------------------------------------------------------- /CHAPTER 09/typedef.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 09/typedef.exe -------------------------------------------------------------------------------- /CHAPTER 10/Basicsof_file.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *ptr; 5 | //for reading the file 6 | ptr=fopen("filw.txt", "r"); 7 | //for writing to a file 8 | // ptr=fopen("filw.txt", "w"); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /CHAPTER 10/Basicsof_file.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/Basicsof_file.exe -------------------------------------------------------------------------------- /CHAPTER 10/a.txt: -------------------------------------------------------------------------------- 1 | hey there -------------------------------------------------------------------------------- /CHAPTER 10/ayush.txt: -------------------------------------------------------------------------------- 1 | The number is 45 Thanks for using fprintf -------------------------------------------------------------------------------- /CHAPTER 10/b.txt: -------------------------------------------------------------------------------- 1 | hheeyy tthheerree -------------------------------------------------------------------------------- /CHAPTER 10/fgetc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *getptr; 5 | getptr=fopen("getcdemo.txt","r"); 6 | // fgetc used for reading a file 7 | // char c=fgetc(getptr); 8 | printf("%c",fgetc(getptr)); 9 | printf("%c",fgetc(getptr)); 10 | printf("%c",fgetc(getptr)); 11 | printf("%c",fgetc(getptr)); 12 | printf("%c",fgetc(getptr)); 13 | printf("%c",fgetc(getptr)); 14 | printf("%c",fgetc(getptr)); 15 | printf("%c",fgetc(getptr)); 16 | printf("%c",fgetc(getptr)); 17 | printf("%c",fgetc(getptr)); 18 | printf("%c",fgetc(getptr)); 19 | printf("%c",fgetc(getptr)); 20 | printf("%c",fgetc(getptr)); 21 | printf("%c",fgetc(getptr)); 22 | printf("%c",fgetc(getptr)); 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /CHAPTER 10/fgetc_fputc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/fgetc_fputc.exe -------------------------------------------------------------------------------- /CHAPTER 10/file.txt: -------------------------------------------------------------------------------- 1 | 34 898 -------------------------------------------------------------------------------- /CHAPTER 10/file_reading.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE*ptr; 5 | int num; 6 | int num1; 7 | ptr=fopen("file.txt","r"); 8 | // ptr=fopen("file.txt","r"); 9 | fscanf(ptr,"%d",&num); 10 | fscanf(ptr,"%d",&num1); 11 | printf("The number is %d\n",num); 12 | printf("The number is %d",num1); 13 | fclose(ptr); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /CHAPTER 10/file_reading.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/file_reading.exe -------------------------------------------------------------------------------- /CHAPTER 10/file_writing.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *fptr; 5 | int num=45; 6 | fptr=fopen("ayush.txt","w"); 7 | fprintf(fptr,"The number is %d",num); 8 | fprintf(fptr," Thanks for using fprintf",num); 9 | fclose(fptr); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /CHAPTER 10/file_writing.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/file_writing.exe -------------------------------------------------------------------------------- /CHAPTER 10/filw.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/filw.txt -------------------------------------------------------------------------------- /CHAPTER 10/fputc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE*putptr; 5 | putptr=fopen("putcdemo.txt","w"); 6 | fputc('Z',putptr); 7 | fputc('y',putptr); 8 | fputc('d',putptr); 9 | fputc('u',putptr); 10 | fputc('S',putptr); 11 | fputc('!',putptr); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /CHAPTER 10/fputc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/fputc.exe -------------------------------------------------------------------------------- /CHAPTER 10/getcdemo.txt: -------------------------------------------------------------------------------- 1 | Hey! I am Zydus FF. -------------------------------------------------------------------------------- /CHAPTER 10/output.txt: -------------------------------------------------------------------------------- 1 | A, 0 -------------------------------------------------------------------------------- /CHAPTER 10/ptr01.txt: -------------------------------------------------------------------------------- 1 | 48 89 999 -------------------------------------------------------------------------------- /CHAPTER 10/ptr1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | int a,b,c; 5 | FILE *ptr1; 6 | 7 | ptr1=fopen("ptr01.txt","r"); 8 | fscanf(ptr1,"%d %d %d",&a,&b,&c); 9 | printf("The numbers are %d, %d, %d ",a,b,c); 10 | fclose(ptr1); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /CHAPTER 10/ptr1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/ptr1.exe -------------------------------------------------------------------------------- /CHAPTER 10/ptr2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | FILE *table; 6 | int num; 7 | printf("Enter the nummber yo need the table of "); 8 | scanf("%d",&num); 9 | table = fopen("zydus.txt", "w"); 10 | for (int i = 0; i < 10; i++) 11 | { 12 | fprintf(table, "%d x %d = %d \n", num, i + 1, num * (i + 1)); 13 | } 14 | fclose(table); 15 | printf("Table generated successfully of %d in zyds.txt\n",num); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /CHAPTER 10/ptr2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/ptr2.exe -------------------------------------------------------------------------------- /CHAPTER 10/ptr3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | FILE *ptr1; 6 | FILE *ptr2; 7 | ptr1 = fopen("a.txt", "r"); 8 | ptr2 = fopen("b.txt", "w"); 9 | 10 | char c = fgetc(ptr1); 11 | // char c = fgetc(ptr1); 12 | while (c != EOF) 13 | { 14 | fputc(c, ptr2); 15 | fputc(c, ptr2); 16 | 17 | c = fgetc(ptr1); 18 | } 19 | 20 | 21 | fclose(ptr1); 22 | fclose(ptr2); 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /CHAPTER 10/ptr3.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/ptr3.exe -------------------------------------------------------------------------------- /CHAPTER 10/ptr4.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *ptr; 5 | char name; 6 | int salary; 7 | ptr=fopen("output.txt","w"); 8 | 9 | printf("Enter name and salary\n"); 10 | scanf("%c , %d",&name,&salary); 11 | fprintf(ptr,"%c, %d",name,salary); 12 | 13 | return 0; 14 | } -------------------------------------------------------------------------------- /CHAPTER 10/ptr4.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/ptr4.exe -------------------------------------------------------------------------------- /CHAPTER 10/putcdemo.txt: -------------------------------------------------------------------------------- 1 | ZyduS! -------------------------------------------------------------------------------- /CHAPTER 10/quikquiz.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE*ptr; 5 | int num; 6 | int num1; 7 | ptr=fopen("file12.txt","r"); 8 | if (ptr==NULL) 9 | { 10 | printf("The file does not exist"); 11 | } 12 | else{ 13 | // ptr=fopen("file.txt","r"); 14 | fscanf(ptr,"%d",&num); 15 | fscanf(ptr,"%d",&num1); 16 | printf("The number is %d\n",num); 17 | printf("The number is %d",num1); 18 | fclose(ptr); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /CHAPTER 10/quikquiz.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/quikquiz.exe -------------------------------------------------------------------------------- /CHAPTER 10/read_whole_file.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *read; 5 | read=fopen("getcdemo.txt","r"); 6 | char c=fgetc(read); 7 | while(c!=EOF){ 8 | printf("%c",c); 9 | c=fgetc(read); 10 | } 11 | fclose(read); 12 | return 0; 13 | } -------------------------------------------------------------------------------- /CHAPTER 10/read_whole_file.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 10/read_whole_file.exe -------------------------------------------------------------------------------- /CHAPTER 10/sample_txt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(){ 4 | FILE *ptr; 5 | ptr=fopen("filw.txt","w"); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /CHAPTER 10/zydus.txt: -------------------------------------------------------------------------------- 1 | 62 x 1 = 62 2 | 62 x 2 = 124 3 | 62 x 3 = 186 4 | 62 x 4 = 248 5 | 62 x 5 = 310 6 | 62 x 6 = 372 7 | 62 x 7 = 434 8 | 62 x 8 = 496 9 | 62 x 9 = 558 10 | 62 x 10 = 620 11 | -------------------------------------------------------------------------------- /CHAPTER 11/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "stdio.h": "c" 4 | }, 5 | "C_Cpp.errorSquiggles": "Disabled" 6 | } -------------------------------------------------------------------------------- /CHAPTER 11/01_malloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int *ptr; 7 | // printf("The size of int in my laptop is %d\n",sizeof(int)); 8 | // printf("The size of float in my laptop is %d\n",sizeof(float)); 9 | // printf("The size of char in my laptop is %d\n",sizeof(char)); 10 | ptr = (int *)malloc(6 * sizeof(int)); 11 | for (int i = 0; i < 6; i++) 12 | { 13 | printf("Enter the value of element %d : ", i+1); 14 | scanf("%d", &ptr[i]); 15 | } 16 | for (int i = 0; i < 6; i++) 17 | { 18 | printf("The value of element %d is %d \n", i+1, ptr[i]); 19 | } 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /CHAPTER 11/01_malloc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 11/01_malloc.exe -------------------------------------------------------------------------------- /CHAPTER 11/02_calloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int *ptr; 7 | 8 | ptr = (int *)calloc(6 , sizeof(int)); 9 | for (int i = 0; i < 6; i++) 10 | { 11 | printf("Enter the value of element %d : ", i+1); 12 | scanf("%d", &ptr[i]); 13 | } 14 | for (int i = 0; i < 6; i++) 15 | { 16 | printf("The value of element %d is %d \n", i+1, ptr[i]); 17 | } 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /CHAPTER 11/02_calloc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 11/02_calloc.exe -------------------------------------------------------------------------------- /CHAPTER 11/04_realloc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int *ptr; 7 | ptr = (int *)malloc(6 * sizeof(int)); 8 | for (int i = 0; i < 6; i++) 9 | { 10 | printf("Enter the value of element %d : ", i+1); 11 | scanf("%d", &ptr[i]); 12 | } 13 | for (int i = 0; i < 6; i++) 14 | { 15 | printf("The value of element %d is %d \n", i+1, ptr[i]); 16 | } 17 | 18 | //reallocate ptr using realloc() 19 | ptr=realloc(ptr,10*sizeof(int)); 20 | for (int i = 0; i < 10; i++) 21 | { 22 | printf("Enter the value of element %d : ", i+1); 23 | scanf("%d", &ptr[i]); 24 | } 25 | for (int i = 0; i < 10; i++) 26 | { 27 | printf("The value of element %d is %d \n", i+1, ptr[i]); 28 | } 29 | 30 | return 0; 31 | } -------------------------------------------------------------------------------- /CHAPTER 11/04_realloc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 11/04_realloc.exe -------------------------------------------------------------------------------- /CHAPTER 11/ptr1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | int* ptr; 6 | ptr=(int*)malloc(6*sizeof(int)) 7 | return 0; 8 | } -------------------------------------------------------------------------------- /CHAPTER 11/quiz1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | float *ptr; 7 | float i; 8 | ptr = (float *)malloc(6 * sizeof(float)); 9 | for ( i = 0; i < 6; i++) 10 | { 11 | printf("Enter the value of element %f : ", i+1); 12 | scanf("%f", &ptr[i+1]); 13 | } 14 | for ( i = 0; i < 6; i++) 15 | { 16 | printf("The value of element %f is %f \n", i+1, ptr[i+1]); 17 | } 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /CHAPTER 11/quiz1.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 11/quiz1.exe -------------------------------------------------------------------------------- /CHAPTER 11/quiz2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | int *ptr; 7 | int n; 8 | printf("Enter the size of array :"); 9 | scanf("%d",&n); 10 | ptr = (int *)calloc(n , sizeof(int)); 11 | for (int i = 0; i < n; i++) 12 | { 13 | printf("Enter the value of element %d : ", i+1); 14 | scanf("%d", &ptr[i]); 15 | } 16 | for (int i = 0; i < n; i++) 17 | { 18 | printf("The value of element %d is %d \n", i+1, ptr[i]); 19 | } 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /CHAPTER 11/quiz2.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/CHAPTER 11/quiz2.exe -------------------------------------------------------------------------------- /CHAPTER 11/quiz3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main(){ 5 | int *ptr; 6 | int *ptr2; 7 | ptr=(int*)malloc(6*sizeof(int)); 8 | 9 | for (int i = 0; i < 600; i++) 10 | { 11 | ptr2=(int*)malloc(600*sizeof(int)); 12 | printf("Enter the value of element %d : ", i+1); 13 | scanf("%d", &ptr[i]); 14 | free(ptr2); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /PROJECT 1/game.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | int number, guess, nguesses = 1; 8 | srand(time(0)); 9 | number = rand() % 100 + 1; //generates a random number between 1 to 100 10 | printf("The number is %d\n", number); 11 | do 12 | { 13 | printf("guess the number between 1 to 100\n"); 14 | scanf("%d", &guess); 15 | // if (guess < number) 16 | // { 17 | // printf("Higher number please!\n"); 18 | // } 19 | if (guess == number ) 20 | { 21 | printf("BRAVO! You guessed in first attempt\n"); 22 | } 23 | else if (guess < number) 24 | { 25 | printf("Higher number please!\n"); 26 | } 27 | else if (guess > number) 28 | { 29 | printf("Lowerr number please!\n"); 30 | } 31 | 32 | else 33 | { 34 | printf("you guessed it in %d attempts\n", nguesses); 35 | } 36 | nguesses++; 37 | } while (guess != number); 38 | 39 | return 0; 40 | } -------------------------------------------------------------------------------- /PROJECT 1/game.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/PROJECT 1/game.exe -------------------------------------------------------------------------------- /PROJECT 1/random_nm.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(){ 6 | int number,guess,nguesses=1; 7 | srand(time(0)); 8 | number=rand()%100+1; 9 | printf("the number is %d",number); 10 | return 0; 11 | } -------------------------------------------------------------------------------- /PROJECT 1/random_nm.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/PROJECT 1/random_nm.exe -------------------------------------------------------------------------------- /PROJECT 2/game.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int snakewatergun(char you, char comp){ 6 | 7 | // checking equal coonditions 8 | if (you == comp){ 9 | return 0; 10 | } 11 | //*********************************************** 12 | // checking for unequal conditions 13 | if (you == 's' && comp == 'w'){ 14 | return 1; 15 | } 16 | else if (you == 'w' && comp == 's'){ 17 | return -1; 18 | } 19 | if (you == 'w' && comp == 'g'){ 20 | return 1; 21 | } 22 | else if (you == 'g' && comp == 'w'){ 23 | return -1; 24 | } 25 | if (you == 'g' && comp == 's'){ 26 | return 1; 27 | } 28 | else if (you == 's' && comp == 'g'){ 29 | return -1; 30 | } 31 | //**************************************************** 32 | } 33 | 34 | int main(){ 35 | char you, comp; 36 | 37 | //Generating random 's', 'g' and 'w' for computer 38 | srand(time(0)); 39 | int number = rand() % 100 + 1; 40 | 41 | if (number < 33){ 42 | comp = 's'; 43 | } 44 | else if (number > 33 && number < 66){ 45 | comp = 'w'; 46 | } 47 | else{ 48 | comp = 'g'; 49 | } 50 | //************************************************* 51 | printf("Enter 's' for snake, 'w' for water and 'g' for gun\n"); 52 | // choosing 's', 'g' and 'w' for player 53 | scanf("%c", &you); 54 | 55 | //calling the function 56 | int result = snakewatergun(you, comp); 57 | if (result == 1){ 58 | printf("You win !\n"); 59 | } 60 | else if (result == -1){ 61 | printf("You lose !\n"); 62 | } 63 | else{ 64 | printf("Game Draw !\n"); 65 | } 66 | //******************************************************** 67 | printf("you choose '%c' and computer choose '%c' \n", you, comp); 68 | printf("\n"); 69 | printf("**********************************************************\n"); 70 | return 0; 71 | } -------------------------------------------------------------------------------- /PROJECT 2/game.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AyushSoni86/C-PROGRAMMING/989d9decaedf544e2c93cc2630e7190f508b57c6/PROJECT 2/game.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # C-PRROGRAMMING 2 | --------------------------------------------------------------------------------