├── #define.c ├── ArithmeticOperation.c ├── ArithmeticOperation.exe ├── Array Of Pointer.c ├── Array.c ├── Array.exe ├── ArrayOfPointer.exe ├── AssignmentOperation.c ├── AssignmentOperation.exe ├── Break.c ├── Break.exe ├── Call By Reference.c ├── Call By Value.c ├── CallByReference.exe ├── CallByValue.exe ├── Calloc.c ├── Calloc.exe ├── Command Line.c ├── CommandLine.exe ├── Continue.c ├── Contiune.exe ├── DataType.c ├── DataType.exe ├── Do While Loop.c ├── DoWhile.exe ├── Error Handling.c ├── ErrorHandling.exe ├── EscapeSequence.c ├── EscapeSequence.exe ├── For Loop.c ├── ForLoop.exe ├── Function.c ├── Function.exe ├── IncrementPointer.exe ├── Infinite Loop.c ├── InfiniteLoop.exe ├── LogicalOperation.c ├── LogicalOperation.exe ├── Maayon.txt ├── Malloc.c ├── Malloc.exe ├── MiscOperation.c ├── MiscOperation.exe ├── Multi Dim Array.c ├── MultiDimArray.exe ├── Nested Loop.c ├── Nested Switch.c ├── Nested if.c ├── NestedIf.exe ├── NestedLoop.exe ├── NestedSwitch.exe ├── Null Pointer.c ├── NullPointer.exe ├── OperatorsPrecedence.c ├── OperatorsPrecedence.exe ├── Pointer Decrement.c ├── Pointer Increment.c ├── Pointer To Function.c ├── Pointer To Pointer.c ├── Pointer To Structure.c ├── Pointer.c ├── PointerDecrement.exe ├── PointerToFunction.exe ├── PointerToPointer.exe ├── PointerToStructure.exe ├── README.md ├── Read File.c ├── ReadFile.exe ├── Realloc Free.c ├── ReallocFree.exe ├── Recursion.c ├── Recursion.exe ├── RelationalOperation.c ├── RelationalOperation.exe ├── Scope Rule.c ├── ScopeRule.exe ├── SimpleCProgram.c ├── SimpleCProgram.exe ├── SimpleIF.c ├── SimpleIF.exe ├── String.c ├── String.exe ├── Structure To Function.c ├── Structure.c ├── Structure.exe ├── StructureToFunction.exe ├── Switch.c ├── Switch.exe ├── TypeDef.c ├── Typecast.c ├── Typecast.exe ├── Typedef in Structure.c ├── Typedef.exe ├── TypedefInStructure.exe ├── Union.c ├── Union.exe ├── Variable.c ├── Variable.exe ├── While Loop.c ├── WhileLoop.exe ├── Write File.c ├── WriteFile.exe ├── define.exe ├── getchar & putchar.c ├── getcharputchar.exe ├── gets puts.c ├── getsputs.exe ├── goto.c ├── goto.exe ├── if else if.c ├── if else.c ├── ifelse.exe ├── ifelseif.exe ├── input.exe ├── pointer.exe ├── scanf printf.c └── scanfprintf.exe /#define.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about #define in C Program*/ 2 | 3 | /*In C Program #define is a keyword which is used to define a variable with a value , which can be used anytime , anywhere in the program .Once a value is decleared in #define it remains same forever in the program*/ 4 | 5 | /*The variable define in #define must be of Capital Letters*/ 6 | 7 | /*In this program lets see a simple #define used in C Programming*/ 8 | 9 | /*Synatx to define a typedef in c programming 10 | 11 | #define Variable value 12 | 13 | */ 14 | 15 | /*including preprocessor in the program*/ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #define PI 3.14 /*defining PI value to 3.14*/ 22 | 23 | /*creating a main() function of the program*/ 24 | 25 | int main() 26 | 27 | { 28 | 29 | printf("\nThe value of PI is : %f\n",PI); 30 | 31 | } -------------------------------------------------------------------------------- /ArithmeticOperation.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing all the Arithemtic Operators like addition , subtraction,multiplication,dividion, modulus etc.. avaliable in C*/ 2 | 3 | /*including preprocessor in the program*/ 4 | 5 | #include 6 | 7 | /*creating a main() function of the program*/ 8 | 9 | int main() 10 | 11 | { 12 | 13 | /*Declearing Variable 'a=21' Variable 'b=10' and creating a Variable 'c' with no initial value declear*/ 14 | 15 | int a = 21; 16 | 17 | int b = 10; 18 | 19 | int c ; 20 | 21 | /*Addition Operation which is used to add the Value present in the Variable 'a' and 'b' and store the Result in Variable 'c'*/ 22 | 23 | c = a + b; 24 | 25 | printf("\nThe Addition of %d and %d is c = %d\n",a,b,c ); 26 | 27 | /*Subtraction Operation which is used to Subtract the Value from Variable 'a' to 'b' and store the Result in Variable 'c'*/ 28 | 29 | c = a - b; 30 | 31 | printf("\nThe Subtarction of %d from %d is c = %d\n",a,b,c ); 32 | 33 | /*Multiplication Operation which is used to Multiply the Value present in the Variable 'a' and 'b' and store the Result in Variable 'c'*/ 34 | 35 | c = a * b; 36 | 37 | printf("\nThe Multiplication of %d and %d is c = %d\n", a,b,c ); 38 | 39 | /*Division Operation which is used to Divide the Value from Variable 'a' by 'b' and store the Result in Variable 'c'*/ 40 | 41 | c = a / b; 42 | 43 | printf("\nThe Division of %d by %d is c = %d\n",a,b, c ); 44 | 45 | /*Modulus Operation which is used to give the remainder when it is divided the Value from Variable 'a' by 'b' and store the Result in Variable 'c'*/ 46 | 47 | c = a % b; 48 | 49 | printf("\nThe Modulus of %d by %d is c = %d\n",a,b,c ); 50 | 51 | /*Increment operator is used to increases the integer value by one.*/ 52 | 53 | a++; 54 | 55 | printf("\nThe Increment Value of a is %d\n",a ); 56 | 57 | /*Decrement operator is used to decreases the integer value by one.*/ 58 | 59 | a--; 60 | 61 | printf("\nThe Decrement Value of a is %d\n",a ); 62 | 63 | } 64 | -------------------------------------------------------------------------------- /ArithmeticOperation.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ArithmeticOperation.exe -------------------------------------------------------------------------------- /Array Of Pointer.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about POINTERS in C Program*/ 2 | 3 | /*Pointer is a type of user defined variable which is used to store the ADDRESS of other variable*/ 4 | 5 | /*pointers are used for dynamic memory allocation ,which is used when we create a dynamic program*/ 6 | 7 | /*In this program lets see about Array of pointer in aprogram*/ 8 | 9 | /*Array of pointer is assigning a Array to any of the pointer variable*/ 10 | 11 | /*including preprocessor in the program*/ 12 | 13 | #include 14 | 15 | /*creating a main() function of the program*/ 16 | 17 | int main() 18 | 19 | { 20 | 21 | int arr[] = {10, 20, 30,40}; 22 | 23 | int i, *ptr[5]; 24 | 25 | /* let us have array address in pointer */ 26 | 27 | for ( i = 0 ; i < 4 ; i++ ) 28 | 29 | { 30 | 31 | ptr[i] = &arr[i]; 32 | 33 | } 34 | 35 | /*printing the value and address of pointer variable*/ 36 | 37 | for ( i = 0 ; i < 4 ; i++ ) 38 | 39 | { 40 | 41 | printf("\nAddress of arr[%d] = %x\n", i, ptr[i] ); 42 | 43 | printf("\nValue of arr[%d] = %d\n", i, *ptr[i] ); 44 | 45 | 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /Array.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about ARRAY in C Program*/ 2 | 3 | /*Array in a C Program is a type of user Defined data type, which is used to store a Collection of data which have same data type.*/ 4 | 5 | /*ADVANTAGE OF ARRAY : When used need to store many values of same data type, he/she can't ale to declear so many Varaile, instead of that he/she can Create an simple Array to store many datas of similar Data Type. */ 6 | 7 | /*DISADVANTAGE : Storeing datas of different data type is not possible in array*/ 8 | 9 | /*IN THIS LET SEE A COMPLETE SINGLE DIMENTIONAL ARRAY*/ 10 | 11 | /*Syntax to Declear a Single Dimentional ARRAY 12 | 13 | DataType ArrayName [ ArraySize ] = { ArraryElements }; 14 | 15 | or 16 | 17 | DataType ArrayName [] = { ArraryElements }; 18 | 19 | */ 20 | 21 | /*Array element can be accessed by using The Array index value , thus array's are stored using index , Usually Array index starts with ZERO.*/ 22 | 23 | /*including preprocessor in the program*/ 24 | 25 | #include 26 | 27 | /*creating a main() function of the program*/ 28 | 29 | int main() 30 | 31 | { 32 | 33 | /*Declearing an array of A*/ 34 | 35 | int arrA[10] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }; 36 | 37 | /*Declearing an array of B*/ 38 | 39 | int arrB[] = { 1 , 2 , 3 , 4 , 5 }; 40 | 41 | /*printing a data's present in an array A*/ 42 | 43 | for ( int i = 0 ; i < 10 ; i++) 44 | 45 | { 46 | 47 | printf("\nThe Value at Array Index of Array A %d is : %d\n", i , arrA[i] ); 48 | 49 | } 50 | 51 | /*printing a data's present in an array B*/ 52 | 53 | for ( int i = 0 ; i < 5 ; i++) 54 | 55 | { 56 | 57 | printf("\nThe Value at Array Index of Array B %d is : %d\n", i , arrB[i] ); 58 | 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /Array.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Array.exe -------------------------------------------------------------------------------- /ArrayOfPointer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ArrayOfPointer.exe -------------------------------------------------------------------------------- /AssignmentOperation.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing all the Assignment Operators like EQUAL TO, ADD And Assignement Operation , SUB And Assignement Operation , MULTI And Assignement Operation , DIVISION And Assignement Operation , MODULUS And Assignement Operation , LEFT SHIFT And Assignement Operation , RIGHT SHIFT And Assignement Operation , Bitewise AND And Assignement Operation , Bitewise inclusive OR And Assignement Operation , Bitewise exclusive OR And Assignement Operation etc... avaliable in C*/ 2 | 3 | /*including preprocessor in the program*/ 4 | 5 | #include 6 | 7 | /*creating a main() function of the program*/ 8 | 9 | int main() 10 | 11 | { 12 | 13 | /*Declearing Variable 'a=10' and creating a Variable 'c' with no initial value declear*/ 14 | 15 | int a = 10; 16 | 17 | int c ; 18 | 19 | /* =(EQUAL TO) Operator Example*/ 20 | 21 | c = a; /* which is c = a */ 22 | 23 | printf("\n = Operator Example, Value of c = %d\n", c ); 24 | 25 | /* += ( ADD And Assignement Operation) Operator Example*/ 26 | 27 | c += a; /* which is c = c + a */ 28 | 29 | printf("\n += ( ADD And Assignement Operation) Operator Example, Value of c = %d\n", c ); 30 | 31 | /* -= ( SUB And Assignement Operation) Operator Example*/ 32 | 33 | c -= a; /* which is c = c - a */ 34 | 35 | printf("\n -= ( SUB And Assignement Operation) Operator Example, Value of c = %d\n", c ); 36 | 37 | /* *= ( MULTI And Assignement Operation) Operator Example*/ 38 | 39 | c *= a; /* which is c = c * a */ 40 | 41 | printf("\n *= ( MULTI And Assignement Operation) Operator Example, Value of c = %d\n", c ); 42 | 43 | /* /= ( DIVISION And Assignement Operation) Operator Example*/ 44 | 45 | c /= a; /* which is c = c / a */ 46 | 47 | printf("\n /= ( DIVISION And Assignement Operation) Operator Example, Value of c = %d\n", c ); 48 | 49 | /* %= ( MODULUS And Assignement Operation) Operator Example*/ 50 | 51 | c = 11; 52 | 53 | c %= a; /* which is c = c % a */ 54 | 55 | printf("\n %%= ( MODULUS And Assignement Operation) Operator Example, Value of c = %d\n", c ); 56 | 57 | /* <<= ( LEFT SHIFT And Assignement Operation) Operator Example*/ 58 | 59 | c = 10; 60 | 61 | c <<= 2; /* which is c = c << 2*/ 62 | 63 | printf("\n <<= ( LEFT SHIFT And Assignement Operation) Operator Example, Value of c = %d\n", c ); 64 | 65 | /* >>= ( RIGHT SHIFT And Assignement Operation) Operator Example*/ 66 | 67 | c >>= 2; /* which is c = c >> 2 */ 68 | 69 | printf("\n >>= ( RIGHT SHIFT And Assignement Operation) Operator Example, Value of c = %d\n", c ); 70 | 71 | /* &= ( BITWISE AND And Assignement Operation) Operator Example*/ 72 | 73 | c &= 2; /* which is c = c & 2 */ 74 | 75 | printf("\n &= ( BITWISE AND And Assignement Operation) Operator Example, Value of c = %d\n", c ); 76 | 77 | /* ^= ( BITWISE EXCLUSIVE OR And Assignement Operation) Operator Example*/ 78 | 79 | c ^= 2; /* which is c = c ^ a */ 80 | 81 | printf("\n ^= ( BITWISE EXCLUSIVE OR And Assignement Operation) Operator Example, Value of c = %d\n", c ); 82 | 83 | /* ^= ( BITWISE INCLUSIVE OR And Assignement Operation) Operator Example*/ 84 | 85 | c |= 2; /* which is c = c | a */ 86 | 87 | printf("\n |= ( BITWISE INCLUSIVE OR And Assignement Operation) Operator Example, Value of c = %d\n", c ); 88 | 89 | } -------------------------------------------------------------------------------- /AssignmentOperation.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/AssignmentOperation.exe -------------------------------------------------------------------------------- /Break.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about LOOPS CONTROL STATEMENTS in C Program*/ 2 | 3 | /*In C break , continue , goto are called as LOOP CONTROL STATEMENT, which is been used for contoling the flow of loop in a c program.*/ 4 | 5 | /*In this Example lets see how break works in a program.*/ 6 | 7 | /*break is a type of loop control statement which is used to terminate a loop, and execute remaining part of a program after loop .*/ 8 | 9 | /*Syntax of break 10 | 11 | break; 12 | 13 | */ 14 | 15 | /*including preprocessor in the program*/ 16 | 17 | #include 18 | 19 | /*creating a main() function of the program*/ 20 | 21 | int main() 22 | 23 | { 24 | 25 | for ( int i = 1 ; i <= 10 ; i++) 26 | 27 | { 28 | 29 | printf("\nValue of i = %d\n",i); 30 | 31 | if ( i == 7) 32 | 33 | { 34 | 35 | printf("\nBreak has been applied . Thus the loop is terminated\n"); 36 | 37 | break; 38 | 39 | } 40 | 41 | } 42 | 43 | printf("\nBreak Statement has executed SUCCESSFULLY.....\n"); 44 | 45 | } -------------------------------------------------------------------------------- /Break.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Break.exe -------------------------------------------------------------------------------- /Call By Reference.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about Functions Arguments in C Program*/ 2 | 3 | /*If a function is to use arguments, it must declare variables that accept the 4 | values of the arguments. These variables are called the formal parameters of 5 | the function.*/ 6 | 7 | /*Ther are 2 types of calling a function in a c program they are "call by value" and " call by reference" . we will see one by one. */ 8 | 9 | /*In this program we will see about " CALL BY REFERENCE"*/ 10 | 11 | /*Call by reference is method used to call a function by using the address of the actual parameters. Thus this method passes the address of actual parameter to the function . Thus any change in a fuction will have an effect with a actual parameters of a main function.*/ 12 | 13 | /*including preprocessor in the program*/ 14 | 15 | #include 16 | 17 | /*creating a user defined function called swap() , which is used to swap the values between them*/ 18 | 19 | void swap( int *x , int *y ) /* int *x , int *y is a parameter list which is passed in the function swap */ 20 | 21 | { 22 | 23 | /*function body which is used to swap two numbers*/ 24 | 25 | /*Declearing local varianble of function swap()*/ 26 | 27 | int temp; 28 | 29 | temp = *x ; /*by this address of x is stored into the variable temp*/ 30 | 31 | *x = *y ; /*by this address of y is stored into the variable x, that is x will have the address of y*/ 32 | 33 | *y = temp ; /*by this value of temp is stored into the variable x, that is y will have the address of x*/ 34 | 35 | printf("\nValue of A , During swap : %d\n", *x ); 36 | 37 | printf("\nValue of B , Before swap : %d\n", *y ); 38 | 39 | 40 | return ; 41 | 42 | } 43 | 44 | /*creating a main() function of the program*/ 45 | 46 | int main() 47 | 48 | { 49 | 50 | /*Declearing local varianble of function main()*/ 51 | 52 | int a = 10 ; 53 | 54 | int b = 20; 55 | 56 | printf("\nValue of A , Before swap : %d\n", a ); 57 | 58 | printf("\nValue of B , Before swap : %d\n", b ); 59 | 60 | swap( &a , &b ); /*calling a user defined function swap*/ 61 | 62 | printf("\nValue of A , After swap : %d\n", a ); 63 | 64 | printf("\nValue of B , After swap : %d\n", b ); 65 | 66 | printf("\nThus value of A and B changes when the function swap called , and remains same after the function call. Thus there is a change in value in main function.\n"); 67 | 68 | } -------------------------------------------------------------------------------- /Call By Value.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about Functions Arguments in C Program*/ 2 | 3 | /*If a function is to use arguments, it must declare variables that accept the 4 | values of the arguments. These variables are called the formal parameters of 5 | the function.*/ 6 | 7 | /*Ther are 2 types of calling a function in a c program they are "call by value" and " call by reference" . we will see one by one. */ 8 | 9 | /*In this program we will see about " CALL BY VALUE "*/ 10 | 11 | /*Call by value is method used to call a function by creating a dumby or duplicate parameters rather than calling the function with the actual parameters. Thus this method passes the actual parameter to an formal parameter , and the function works with a formal parameter rather than with actual parameter. Thus any change in a formal parameter will have no effect with a actual parameters*/ 12 | 13 | /*By Default c program will be following this call by value method*/ 14 | 15 | /*including preprocessor in the program*/ 16 | 17 | #include 18 | 19 | /*creating a user defined function called swap() , which is used to swap the values between them*/ 20 | 21 | void swap( int x , int y ) /* int x , int y is a parameter list which is passed in the function swap */ 22 | 23 | { 24 | 25 | /*function body which is used to swap two numbers*/ 26 | 27 | /*Declearing local varianble of function swap()*/ 28 | 29 | int temp; 30 | 31 | temp = x ; /*by this value of x is stored into the variable temp*/ 32 | 33 | x = y ; /*by this value of y is stored into the variable x, that is x will have the value of y*/ 34 | 35 | y = temp ; /*by this value of temp is stored into the variable x, that is y will have the value of x*/ 36 | 37 | printf("\nValue of A , During swap : %d\n", x ); 38 | 39 | printf("\nValue of B , Before swap : %d\n", y ); 40 | 41 | 42 | return ; 43 | 44 | } 45 | 46 | /*creating a main() function of the program*/ 47 | 48 | int main() 49 | 50 | { 51 | 52 | /*Declearing local varianble of function main()*/ 53 | 54 | int a = 10 ; 55 | 56 | int b = 20; 57 | 58 | printf("\nValue of A , Before swap : %d\n", a ); 59 | 60 | printf("\nValue of B , Before swap : %d\n", b ); 61 | 62 | swap( a , b ); /*calling a user defined function swap*/ 63 | 64 | printf("\nValue of A , After swap : %d\n", a ); 65 | 66 | printf("\nValue of B , After swap : %d\n", b ); 67 | 68 | printf("\nThus value of A and B changes only when it is in the function swap , and remains same before and after the function call. Thus there i no change in value in main function.\n"); 69 | 70 | } -------------------------------------------------------------------------------- /CallByReference.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/CallByReference.exe -------------------------------------------------------------------------------- /CallByValue.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/CallByValue.exe -------------------------------------------------------------------------------- /Calloc.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about Memory Managemet in C Program*/ 2 | 3 | /*In C Program memory can be managed easy by using dynamic memory allocation */ 4 | 5 | /*In this program lets see a calloc() used in C Programming*/ 6 | 7 | /*And lets see how to allocate memory in dynamic manner*/ 8 | 9 | /*Synatx to define a calloc() in c programming 10 | 11 | void *calloc(int num , int size) 12 | 13 | */ 14 | 15 | /*including preprocessor in the program*/ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | int main() 24 | 25 | { 26 | 27 | char name[100]; 28 | 29 | /* allocate memory dynamically */ 30 | 31 | char *work = calloc( 200 , sizeof(char) ); 32 | 33 | strcpy(name, "Mayyon"); 34 | 35 | if( work == NULL ) 36 | 37 | { 38 | 39 | fprintf(stderr, "Error - unable to allocate required memory\n"); 40 | 41 | } 42 | 43 | else 44 | 45 | { 46 | 47 | strcpy( work, "Maayon is a poet"); 48 | 49 | } 50 | 51 | printf("\nName = %s\n", name ); 52 | 53 | printf("\nWork : %s\n", work ); 54 | 55 | } -------------------------------------------------------------------------------- /Calloc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Calloc.exe -------------------------------------------------------------------------------- /Command Line.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about Command line Arguments in C Program*/ 2 | 3 | /*In C Program we can able to pass values from the command line is know as command line arguments*/ 4 | 5 | /*Command line argument is used when user want to control the program from outside rather than inside the program execution.*/ 6 | 7 | /*argc refers to number of arguments passed in the command line*/ 8 | 9 | /*argv[] is a pointer array which is used to point each argument passed in the program*/ 10 | 11 | /*NOTE : argv[0] is always used to point to the program name and its location in the local system*/ 12 | 13 | /*command line argument is passed using main()*/ 14 | 15 | /*syntax for passing command line 16 | 17 | int main ( int argc , char *argv[] ) 18 | 19 | */ 20 | 21 | /*including preprocessor in the program*/ 22 | 23 | #include 24 | 25 | #include 26 | 27 | #include 28 | 29 | /*defining a command line argument in c*/ 30 | 31 | int main( int argc , char *argv[] ) 32 | 33 | { 34 | 35 | if ( argc == 2) 36 | 37 | { 38 | 39 | printf("\nOne command line argument has been passed .\n "); 40 | 41 | printf("\nThe Argument which is passed in command line is : %s\n", argv[1]); 42 | 43 | } 44 | 45 | else if ( argc >= 2) 46 | 47 | { 48 | 49 | printf("\nTwo Arguments have been passed.\n"); 50 | 51 | printf("\nThe First Argument which is passed in command line is : %s\n", argv[1] ); 52 | 53 | printf("\nThe Second Argument which is passed in command line is : %s\n", argv[2] ); 54 | 55 | } 56 | 57 | else 58 | 59 | { 60 | 61 | printf("\nArgument has not passed.\n"); 62 | 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /CommandLine.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/CommandLine.exe -------------------------------------------------------------------------------- /Continue.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about LOOPS CONTROL STATEMENTS in C Program*/ 2 | 3 | /*In C break , continue , goto are called as LOOP CONTROL STATEMENT, which is been used for contoling the flow of loop in a c program.*/ 4 | 5 | /*In this Example lets see how CONTINUE works in a program.*/ 6 | 7 | /*Continue is a type of loop control statement which is used to terminate only particular iteration, and execute next iteration of the loop.*/ 8 | 9 | /*Syntax of continue 10 | 11 | continue; 12 | 13 | */ 14 | 15 | /*including preprocessor in the program*/ 16 | 17 | #include 18 | 19 | /*creating a main() function of the program*/ 20 | 21 | int main() 22 | 23 | { 24 | 25 | for ( int i = 1 ; i <= 10 ; i++) 26 | 27 | { 28 | 29 | if ( i == 7) 30 | 31 | { 32 | 33 | printf("\nContinue has been applied . Thus the next Iteration has taken placed by skipping this particular iteration\n"); 34 | 35 | continue; 36 | 37 | } 38 | 39 | printf("\nValue of i = %d\n",i); 40 | 41 | } 42 | 43 | printf("\nContinue Statement has executed SUCCESSFULLY.....\n"); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Contiune.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Contiune.exe -------------------------------------------------------------------------------- /DataType.c: -------------------------------------------------------------------------------- 1 | /*inculding stdio and limits preprocessor*/ 2 | 3 | #include 4 | #include 5 | 6 | /*main function of the program*/ 7 | int main() 8 | { 9 | /*c as data types like int , shortint, float, char , singned , unsigned etc...*/ 10 | 11 | /*sizeof is a predefined function used to find the size of a variable or data type*/ 12 | 13 | /*In this program is have used '/n' in lot of places , it a special character or excape sequence used for next line , Don't worry this topic will be covered later on */ 14 | 15 | /* finding storage size for int*/ 16 | 17 | printf("\nStorage size for int : %d \n", sizeof(int)); 18 | 19 | printf("\nStorage size for unsigned int : %d \n", sizeof(unsigned int)); 20 | 21 | printf("\nStorage size for signed int : %d \n", sizeof(signed int)); 22 | 23 | /* finding storage size for char*/ 24 | 25 | printf("\nStorage size for char : %d \n", sizeof(char)); 26 | 27 | printf("\nStorage size for unsigned char : %d \n", sizeof(unsigned char)); 28 | 29 | printf("\nStorage size for signed char : %d \n", sizeof(signed char)); 30 | 31 | /* finding storage size for short*/ 32 | 33 | printf("\nStorage size for short : %d \n", sizeof(short)); 34 | 35 | printf("\nStorage size for unsigned short : %d \n", sizeof(unsigned short)); 36 | 37 | printf("\nStorage size for signed short : %d \n", sizeof(signed short)); 38 | 39 | /* finding storage size for long*/ 40 | 41 | printf("\nStorage size for long : %d \n", sizeof(long)); 42 | 43 | printf("\nStorage size for unsigned long : %d \n", sizeof(unsigned long)); 44 | 45 | printf("\nStorage size for signed long : %d \n", sizeof(signed long)); 46 | 47 | /* finding storage size for float*/ 48 | 49 | printf("\nStorage size for float : %d \n", sizeof(float)); 50 | 51 | /* finding storage size for double*/ 52 | 53 | printf("\nStorage size for double : %d \n", sizeof(double)); 54 | 55 | /* finding storage size for long double*/ 56 | 57 | printf("\nStorage size for long double : %d \n", sizeof(long double)); 58 | 59 | } -------------------------------------------------------------------------------- /DataType.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/DataType.exe -------------------------------------------------------------------------------- /Do While Loop.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about LOOPS in C Program*/ 2 | 3 | /*In C while, do while, for are different loop Statements , which is used to execute certain number of codes for certain number of times. That is the code inside the loop will be execute certain number of times till the condition fails and loop comes out of the scope.*/ 4 | 5 | /*In this Example lets see how DO WHILE LOOP works in a program.*/ 6 | 7 | /*Do While loop is kind of LOOP , which is used to execute the code for certain number of times, till the condition fails. Do While loop is also know as 'EXIT CHECK LOOP',that is loop will execute atleast once even though the condition fails.*/ 8 | 9 | /*Syntax of do while loop 10 | 11 | do 12 | 13 | { 14 | 15 | Statement(S) / block of code; 16 | 17 | Increment; 18 | 19 | }while(condition) 20 | 21 | */ 22 | 23 | /*including preprocessor in the program*/ 24 | 25 | #include 26 | 27 | /*creating a main() function of the program*/ 28 | 29 | int main() 30 | 31 | { 32 | 33 | /* local variable definition */ 34 | 35 | int a = 0 ; 36 | 37 | /*Do while loop*/ 38 | 39 | do 40 | 41 | { 42 | 43 | printf("\nValue of a = %d\n",a); 44 | 45 | printf("\nThe DO WHILE LOOP is executed for %d\n",a); 46 | 47 | a++; /*Increment the value of variable a */ 48 | 49 | }while ( a < 0 ) ; /*do While loop condition,Where condition will be checked.*/ /*End of while loop */ 50 | 51 | printf("\nThe DO WHILE LOOP is executed for %d number of times\n",a); 52 | 53 | } -------------------------------------------------------------------------------- /DoWhile.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/DoWhile.exe -------------------------------------------------------------------------------- /Error Handling.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about ERROR HANDLING in C Program*/ 2 | 3 | /*In this program let see how to handle errors in c program.*/ 4 | 5 | /*Error handling is a method to handle all the occurance of errors in c programming*/ 6 | 7 | /*note c program doesn't provide direct support to error handling*/ 8 | 9 | /*including preprocessor in the program*/ 10 | 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | 17 | /*creating a main() function of the program*/ 18 | 19 | void main() 20 | 21 | { 22 | 23 | int errnum; 24 | 25 | int errno; 26 | 27 | /*trying to open an file which is not existing*/ 28 | 29 | FILE *fileptr = fopen ("123456.txt", "r"); 30 | 31 | if (fileptr == NULL) 32 | 33 | { 34 | 35 | errnum = errno; 36 | 37 | perror("\nError printed by perror "); 38 | 39 | fprintf(stderr, "\n\nError opening file : %s\n", strerror( errnum )); 40 | 41 | } 42 | 43 | else 44 | 45 | { 46 | 47 | fclose (fileptr); 48 | 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /ErrorHandling.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ErrorHandling.exe -------------------------------------------------------------------------------- /EscapeSequence.c: -------------------------------------------------------------------------------- 1 | /*inculding preprocessor*/ 2 | 3 | #include 4 | 5 | /*main function of a programing*/ 6 | 7 | int main() 8 | { 9 | 10 | /*Here Manjor Escape Sequence are explained here*/ 11 | 12 | printf("\nBalck Slash will be printed : \\ \n"); 13 | 14 | printf("\nSingle quotes will be printed : \' \n"); 15 | 16 | printf("\nDouble quotes will be printed : \'' \n"); 17 | 18 | printf("\nQuestion mark will be printed : \? \n"); 19 | 20 | printf("\nAlert or bell sound will be produced : \a \n"); 21 | 22 | printf("\nBackSpace Key function will be done : \b\bsuccessfully \n"); 23 | 24 | printf("\nForm Feed will be printed : \f successfully in the program \n"); 25 | 26 | printf("\nNew line will be printed : \nsuccessfully\n "); 27 | 28 | printf("\nHorizontal tab will be printed : \tsuccessfully\n "); 29 | 30 | printf("\nVertical tab will be printed : \vsuccessfully\n "); 31 | 32 | } 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /EscapeSequence.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/EscapeSequence.exe -------------------------------------------------------------------------------- /For Loop.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about LOOPS in C Program*/ 2 | 3 | /*In C while, do while, for are different loop Statements , which is used to execute certain number of codes for certain number of times. That is the code inside the loop will be execute certain number of times till the condition fails and loop comes out of the scope.*/ 4 | 5 | /*In this Example lets see how FOR LOOP works in a program.*/ 6 | 7 | /*for loop is kind of LOOP , which is used to execute the code for certain number of times, till the condition fails. for loop is also know as predefined loops , which is the user might know how many times will the loop being executed.that is loop will be execute only is the condition is True, if the condition is fails then the loop stop executing.*/ 8 | 9 | /*Syntax of for loop 10 | 11 | for ( init ; condition ; increment ) 12 | 13 | { 14 | 15 | Statement(S) / block of code; 16 | 17 | } 18 | 19 | */ 20 | 21 | /*In for loop the initiation, condition and incrementation will be occcured as same line */ 22 | 23 | /*including preprocessor in the program*/ 24 | 25 | #include 26 | 27 | /*creating a main() function of the program*/ 28 | 29 | int main() 30 | 31 | { 32 | 33 | int a ; 34 | 35 | for ( a = 1 ; a <= 10 ; a++ ) /*for loop initalization is used to initalize the loop varaiable which is to be executed, for loop is condition,Where condition will be checked, Increment is used to increment the value of the variable.*/ 36 | 37 | { 38 | 39 | printf("\nValue of a = %d\n",a); 40 | 41 | printf("\nThe FOR LOOP is executed for %d\n",a); 42 | 43 | } /*End of for loop */ 44 | 45 | printf("\nThe FOR LOOP is executed for %d number of times\n",a-=1); 46 | 47 | } -------------------------------------------------------------------------------- /ForLoop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ForLoop.exe -------------------------------------------------------------------------------- /Function.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about Functions in C Program*/ 2 | 3 | /*Function is a group of statements / code formed together for doing a specific task in a C program*/ 4 | 5 | /*NOTE : C program atleast must have one function , the default function is called as main()*/ 6 | 7 | /*Functions used are used to call specific code whenever needed in the program, Thus functions are used for code reuseability*/ 8 | 9 | /*Synatx for creating a user defined function 10 | 11 | return_type function_name( parameter list ) 12 | 13 | { 14 | 15 | body of the function 16 | 17 | } 18 | 19 | */ 20 | 21 | /*including preprocessor in the program*/ 22 | 23 | #include 24 | 25 | /*creating a user defined function called add()*/ 26 | 27 | int add( int x , int y ) /* int x , int y is a parameter list which is passed in the function add */ 28 | 29 | { 30 | 31 | /*function body which is used to add two numbers*/ 32 | 33 | /*Declearing local varianble of function add()*/ 34 | 35 | int sum; 36 | 37 | sum = x +y ; 38 | 39 | return sum ; 40 | 41 | } 42 | 43 | /*creating a main() function of the program*/ 44 | 45 | int main() 46 | 47 | { 48 | 49 | /*Declearing local varianble of function main()*/ 50 | 51 | int a = 10 ; 52 | 53 | int b = 20; 54 | 55 | int c = 30; 56 | 57 | int sum; 58 | 59 | sum = add ( a , b ); /*calling the function add into the main program*/ 60 | 61 | printf("\nThe addition of value %d and % d is : %d\n", a , b , sum); 62 | 63 | sum = add ( a , c ); /*calling the function add into the main program*/ 64 | 65 | printf("\nThe addition of value %d and % d is : %d\n", a , c , sum); 66 | 67 | sum = add ( b , c ); /*calling the function add into the main program*/ 68 | 69 | printf("\nThe addition of value %d and % d is : %d\n", b , c , sum); 70 | 71 | } -------------------------------------------------------------------------------- /Function.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Function.exe -------------------------------------------------------------------------------- /IncrementPointer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/IncrementPointer.exe -------------------------------------------------------------------------------- /Infinite Loop.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about INFINITE LOOP in C Program*/ 2 | 3 | /*An infinite loop is a loop that run last long and inifinite loop occures only when thr condition wont fail forever*/ 4 | 5 | /*including preprocessor in the program*/ 6 | 7 | #include 8 | 9 | /*creating a main() function of the program*/ 10 | 11 | int main() 12 | 13 | { 14 | 15 | /*Note : This program will be resulting in infinite loop*/ 16 | 17 | /*Note : To STOP inifinite loop press Ctrl + c.*/ 18 | 19 | for ( ; ; ) 20 | 21 | { 22 | printf("\ninfinite loop Runs for forever\n"); 23 | 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /InfiniteLoop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/InfiniteLoop.exe -------------------------------------------------------------------------------- /LogicalOperation.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing all the Logical Operators like AND , OR , NOT avaliable in C*/ 2 | 3 | /*including preprocessor in the program*/ 4 | 5 | #include 6 | 7 | /*creating a main() function of the program*/ 8 | 9 | int main() 10 | 11 | { 12 | 13 | /*Declearing Variable 'a=0' Variable 'b=20' and creating a Variable 'c' with no initial value declear*/ 14 | 15 | int a = 0; 16 | 17 | int b = 20; 18 | 19 | int c ; 20 | 21 | /* Now checking for AND condition that if a and b contains an all NON Zero value then it pass the condition else it will not pass the condition*/ 22 | 23 | if ( a && b ) 24 | 25 | { 26 | 27 | printf("\nCondition is True and LOGICAL AND condition is Passed.\n" ); 28 | 29 | } 30 | 31 | else 32 | 33 | { 34 | 35 | printf("\nCondition is False and LOGICAL AND condition is Not -Passed.\n" ); 36 | 37 | } 38 | 39 | /* Now checking for OR condition that if a and b contains an any NON Zero value then it pass the condition else it will not pass the condition*/ 40 | 41 | if ( a || b ) 42 | 43 | { 44 | 45 | printf("\nCondition is True and LOGICAL OR condition is Passed.\n" ); 46 | 47 | } 48 | 49 | else 50 | { 51 | 52 | printf("\nCondition is False and LOGICAL OR condition is Not-Passed.\n" ); 53 | 54 | } 55 | 56 | /* Now checking for NOT condition then it will pass the condition in Reverse Order such that If answer is True then Result will be printed as False, similarly If answer is False then Result will be printed as True*/ 57 | 58 | if ( !(a && b) ) 59 | 60 | { 61 | 62 | printf("\nCondition is True and LOGICAL NOT condition is Passed.\n" ); 63 | 64 | } 65 | 66 | else 67 | 68 | { 69 | 70 | printf("\nCondition is False and LOGICAL NOT condition is Not-Passed.\n" ); 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /LogicalOperation.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/LogicalOperation.exe -------------------------------------------------------------------------------- /Maayon.txt: -------------------------------------------------------------------------------- 1 | This is Maayon... 2 | 3 | This is my first program in Files in C Program... 4 | -------------------------------------------------------------------------------- /Malloc.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about Memory Managemet in C Program*/ 2 | 3 | /*In C Program memory can be managed easy by using dynamic memory allocation */ 4 | 5 | /*In this program lets see a malloc() used in C Programming*/ 6 | 7 | /*And lets see how to allocate memory in dynamic manner*/ 8 | 9 | /*Synatx to define a malloc() in c programming 10 | 11 | void *malloc(int num) 12 | 13 | */ 14 | 15 | /*including preprocessor in the program*/ 16 | 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | int main() 24 | 25 | { 26 | 27 | char name[100]; 28 | 29 | /* allocate memory dynamically */ 30 | 31 | char *work = malloc( 200 * sizeof(char) ); 32 | 33 | strcpy(name, "Mayyon"); 34 | 35 | if( work == NULL ) 36 | 37 | { 38 | 39 | fprintf(stderr, "Error - unable to allocate required memory\n"); 40 | 41 | } 42 | 43 | else 44 | 45 | { 46 | 47 | strcpy( work, "Maayon is a poet"); 48 | 49 | } 50 | 51 | printf("\nName = %s\n", name ); 52 | 53 | printf("\nWork : %s\n", work ); 54 | 55 | } -------------------------------------------------------------------------------- /Malloc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Malloc.exe -------------------------------------------------------------------------------- /MiscOperation.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing all the Misc Operators like Sizeof,Adress , pointer , Conditional Expression avaliable in C*/ 2 | 3 | /*including preprocessor in the program*/ 4 | 5 | #include 6 | 7 | /*creating a main() function of the program*/ 8 | 9 | int main() 10 | 11 | { 12 | 13 | /*Declearing Variable 'a=10' of data type int ,creating a Variable 'b' with no initial value with datatype float and creating a Variable 'c' with no initial value with datatype double declear and pointer is created*/ 14 | 15 | /*Note: No worries about pointer , address and conditional Expression, it will explained later on */ 16 | 17 | int a = 10; 18 | 19 | float b; 20 | 21 | double c; 22 | 23 | int* ptr; 24 | 25 | /* example of sizeof operator */ 26 | 27 | printf("\nSize of variable 'a' of data type int = %d\n", sizeof(a) ); 28 | 29 | printf("\nSize of variable 'b' of data type float = %d\n", sizeof(b) ); 30 | 31 | printf("\nSize of variable 'c' of data type double = %d\n", sizeof(c) ); 32 | 33 | /* example of & and * operators */ 34 | 35 | /*Address(&) is used to return the address of a variable stored*/ 36 | 37 | ptr = &a; /* 'ptr' now contains the address of 'a'*/ 38 | 39 | printf("\nvalue of a is %d\n", a); 40 | 41 | printf("\nAddress of a is %d\n", &a); 42 | 43 | printf("\nValue of *ptr is %d.\n", ptr); 44 | 45 | printf("\n*ptr is %d.\n", *ptr); 46 | 47 | /* example of ternary operator */ 48 | 49 | /*conditional operator is also known as Ternary Operator it is defined as when the condition is true then first expression will excuted , if the condition fails then second expression will be excuted . Syntax for Ternary Operator is "Variable = Condition ? Expression 1 :Expression2;"*/ 50 | 51 | int x = 10; 52 | 53 | int y = 30; 54 | 55 | int z = ( x < y ) ? x : y ; 56 | 57 | printf( "\nValue of z is %d\n",z ); 58 | 59 | } -------------------------------------------------------------------------------- /MiscOperation.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/MiscOperation.exe -------------------------------------------------------------------------------- /Multi Dim Array.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about ARRAY in C Program*/ 2 | 3 | /*Array in a C Program is a type of user Defined data type, which is used to store a Collection of data which have same data type.*/ 4 | 5 | /*ADVANTAGE OF ARRAY : When used need to store many values of same data type, he/she can't ale to declear so many Varaile, instead of that he/she can Create an simple Array to store many datas of similar Data Type. */ 6 | 7 | /*DISADVANTAGE : Storeing datas of different data type is not possible in array*/ 8 | 9 | /*IN THIS LET SEE A COMPLETE TWO / MULTI DIMENTIONAL ARRAY*/ 10 | 11 | /*Syntax to Declear a Two or Multi Dimentional ARRAY 12 | 13 | DataType ArrayName [ ArraySize of 1 ] [ ArraySize of 2 ] ... [ArraySize of N ] = { ArraryElements }; 14 | 15 | */ 16 | 17 | /*Array element can be accessed by using The Array index value , thus array's are stored using index , Usually Array index starts with ZERO.*/ 18 | 19 | /*including preprocessor in the program*/ 20 | 21 | #include 22 | 23 | /*creating a main() function of the program*/ 24 | 25 | int main() 26 | 27 | { 28 | 29 | /*Declearing an two dimension array of A*/ 30 | 31 | /*Example for Two Dimentional Array is MATRIX*/ 32 | 33 | int arrA[3][3] ={ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9} ; 34 | 35 | /*printing a data's present in an array A*/ 36 | 37 | for ( int i = 0 ; i < 3 ; i++) 38 | 39 | { 40 | for ( int j = 0 ; j < 3 ; j++) 41 | 42 | { 43 | 44 | printf("\nA[%d][%d] = %d\n", i , j , arrA[i][j] ); 45 | } 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /MultiDimArray.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/MultiDimArray.exe -------------------------------------------------------------------------------- /Nested Loop.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about LOOPS in C Program*/ 2 | 3 | /*In C while, do while, for are different loop Statements , which is used to execute certain number of codes for certain number of times. That is the code inside the loop will be execute certain number of times till the condition fails and loop comes out of the scope.*/ 4 | 5 | /*In this Example lets see how NESTED LOOP works in a program.*/ 6 | 7 | /*Nested loops is similar to loop concept but where in this nested loop a loop can be nested another loop.*/ 8 | 9 | /*Syntax of nested for loop 10 | 11 | for ( init ; condition ; increment ) 12 | 13 | { 14 | 15 | for ( init ; condition ; increment ) 16 | 17 | { 18 | 19 | Statement(S) / block of code; 20 | 21 | } 22 | 23 | Statement(S) / block of code; 24 | 25 | } 26 | 27 | */ 28 | 29 | /*Syntax of nested While loop 30 | 31 | while ( condition ) 32 | 33 | { 34 | 35 | while ( condition ) 36 | 37 | { 38 | 39 | Statement(S) / block of code; 40 | 41 | } 42 | 43 | Statement(S) / block of code; 44 | 45 | } 46 | 47 | */ 48 | 49 | /*Syntax of nested do While loop 50 | 51 | do 52 | 53 | { 54 | 55 | Statement(S) / block of code; 56 | 57 | do 58 | 59 | { 60 | 61 | Statement(S) / block of code; 62 | 63 | }while ( condition ); 64 | 65 | }while ( condition ); 66 | 67 | */ 68 | 69 | /*including preprocessor in the program*/ 70 | 71 | #include 72 | 73 | /*creating a main() function of the program*/ 74 | 75 | int main() 76 | 77 | { 78 | 79 | for ( int i = 1 ; i <= 5 ; i++) 80 | 81 | { 82 | 83 | printf("\nOUTER FOR LOOP is executed for %d\n",i); 84 | 85 | for ( int j = 1 ; j <= 5 ; j++) 86 | 87 | { 88 | 89 | printf("\nINNER FOR LOOP is executed for %d\n",j); 90 | 91 | } 92 | 93 | } 94 | 95 | } -------------------------------------------------------------------------------- /Nested Switch.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing Decision Making Statements*/ 2 | 3 | /*In C if, if else, nested if , switch , nested Switch are know as Decision Making Statements , which is used to have decision based up on the condition , the statement is executed.*/ 4 | 5 | /*In this Example lets see how NESTED SWITCH Statement works in a program.*/ 6 | 7 | /*Switch contains a expression , if the expression meets any equality with the case, then the code/statement/block inside that cse will be executed and remaining cases will be ignored by the compiler.*/ 8 | 9 | /*Note : switch can have any number of case in it.*/ 10 | 11 | /*Syntax of NESTED Switch statement 12 | 13 | switch(expressionq1){ 14 | 15 | case constant-expression : 16 | 17 | statement(s); 18 | 19 | switch(expressionq2){ 20 | 21 | case constant-expression : 22 | 23 | statement(s); 24 | 25 | break; 26 | 27 | case constant-expression : 28 | 29 | statement(s); 30 | 31 | break; 32 | 33 | default : 34 | 35 | statement(s); 36 | 37 | } 38 | 39 | break; 40 | 41 | case constant-expression : 42 | 43 | statement(s); 44 | 45 | break; 46 | 47 | default : 48 | 49 | statement(s); 50 | 51 | } 52 | 53 | */ 54 | 55 | /*It is optional to have 'break statement' at end of each case, but it is good pratice to have 'break statement' at end of each case, since it breaks the remaining case and only execute needed case*/ 56 | 57 | /*When no cases statisfy the condition ,then default case will be executed*/ 58 | 59 | /*including preprocessor in the program*/ 60 | 61 | #include 62 | 63 | /*creating a main() function of the program*/ 64 | 65 | int main() 66 | 67 | { 68 | 69 | /* local variable definition */ 70 | 71 | int choisea = 2 ; /*choise a= 2*/ 72 | 73 | int choiseb = 3 ; /*choise b= 3*/ 74 | 75 | /*when the switch case meets the condition then that case will be executed*/ 76 | 77 | /*In this when case is equal to choise then than case will be executed*/ 78 | 79 | /*In this I have designed to execute normal cases*/ 80 | 81 | printf("\nlets see now normal cases in nested switch.\n"); 82 | 83 | switch(choisea) 84 | { 85 | 86 | case 1 : 87 | 88 | printf("\nCase 1 of OUTER SWITCH is Executed ,Since Choise of A is 1\n"); 89 | 90 | switch(choiseb) 91 | { 92 | 93 | case 1 : 94 | 95 | printf("\nCase 1 of INNER SWITCH is Executed ,Since Choise of B is 1\n"); 96 | 97 | break ; 98 | 99 | 100 | case 2 : 101 | 102 | printf("\nCase 2 of INNER SWITCH is Executed ,Since Choise of B is 2\n"); 103 | 104 | break ; 105 | 106 | case 3 : 107 | 108 | printf("\nCase 3 of INNER SWITCH is Executed ,Since Choise of B is 3\n"); 109 | 110 | break ; 111 | 112 | case 4 : 113 | 114 | printf("\nCase 4 of INNER SWITCH is Executed ,Since Choise of B is 4\n"); 115 | 116 | break ; 117 | 118 | default : 119 | 120 | printf("\nSince no Case is met with Choise of B ,Therefore default case is Executed\n"); 121 | 122 | break ; 123 | 124 | } 125 | 126 | break ; 127 | 128 | 129 | case 2 : 130 | 131 | printf("\nCase 2 of OUTER SWITCH is Executed ,Since Choise of A is 2\n"); 132 | 133 | switch(choiseb) 134 | { 135 | 136 | case 1 : 137 | 138 | printf("\nCase 1 of INNER SWITCH is Executed ,Since Choise of B is 1\n"); 139 | 140 | break ; 141 | 142 | 143 | case 2 : 144 | 145 | printf("\nCase 2 of INNER SWITCH is Executed ,Since Choise of B is 2\n"); 146 | 147 | break ; 148 | 149 | case 3 : 150 | 151 | printf("\nCase 3 of INNER SWITCH is Executed ,Since Choise of B is 3\n"); 152 | 153 | break ; 154 | 155 | case 4 : 156 | 157 | printf("\nCase 4 of INNER SWITCH is Executed ,Since Choise of B is 4\n"); 158 | 159 | break ; 160 | 161 | default : 162 | 163 | printf("\nSince no Case is met with Choise of B ,Therefore default case is Executed\n"); 164 | 165 | break ; 166 | 167 | } 168 | 169 | break ; 170 | 171 | case 3 : 172 | 173 | printf("\nCase 3 of OUTER SWITCH is Executed ,Since Choise of A is 3\n"); 174 | 175 | switch(choiseb) 176 | { 177 | 178 | case 1 : 179 | 180 | printf("\nCase 1 of INNER SWITCH is Executed ,Since Choise of B is 1\n"); 181 | 182 | break ; 183 | 184 | 185 | case 2 : 186 | 187 | printf("\nCase 2 of INNER SWITCH is Executed ,Since Choise of B is 2\n"); 188 | 189 | break ; 190 | 191 | case 3 : 192 | 193 | printf("\nCase 3 of INNER SWITCH is Executed ,Since Choise of B is 3\n"); 194 | 195 | break ; 196 | 197 | case 4 : 198 | 199 | printf("\nCase 4 of INNER SWITCH is Executed ,Since Choise of B is 4\n"); 200 | 201 | break ; 202 | 203 | default : 204 | 205 | printf("\nSince no Case is met with Choise of B ,Therefore default case is Executed\n"); 206 | 207 | break ; 208 | 209 | } 210 | 211 | break ; 212 | 213 | default : 214 | 215 | printf("\nSince no Case is met with Choise of A ,Therefore default case is Executed\n"); 216 | 217 | break ; 218 | 219 | } 220 | 221 | } -------------------------------------------------------------------------------- /Nested if.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing Decision Making Statements*/ 2 | 3 | /*In C if, if else, nested if , switch , nested Switch are know as Decision Making Statements , which is used to have decision based up on the condition , the statement is executed*/ 4 | 5 | /*In this Example lets see how NESTED IF Statement works in a program*/ 6 | 7 | /*It is always legal in C programming to nest if-else statements, which means you 8 | can use one if or else if statement inside another if or else if statement(s).*/ 9 | 10 | /*You can nest else if...else in the similar way as you have nested if statements.*/ 11 | 12 | /*You can nest if...else in the similar way as you have nested if statements.*/ 13 | 14 | /*Syntax of NESTED IF statement 15 | 16 | if(boolean_expression1) 17 | 18 | { 19 | 20 | statement 1; 21 | 22 | statement 2; 23 | 24 | . 25 | . 26 | . 27 | 28 | statement n; 29 | 30 | if(boolean_expression2) 31 | 32 | { 33 | 34 | statement 1; 35 | 36 | statement 2; 37 | 38 | . 39 | . 40 | . 41 | 42 | statement n; 43 | 44 | } 45 | 46 | } 47 | */ 48 | 49 | /*including preprocessor in the program*/ 50 | 51 | #include 52 | 53 | /*creating a main() function of the program*/ 54 | 55 | int main() 56 | 57 | { 58 | 59 | /* local variable definition */ 60 | 61 | int a = 10; 62 | 63 | int b = 20; 64 | 65 | /* check the boolean condition using if statement */ 66 | 67 | /*In this "IF" condition is True therefore the statements/code inside will be Executed Succesfully*/ 68 | 69 | if( a > 20 ) 70 | 71 | { 72 | 73 | /* if condition is true then print the following */ 74 | 75 | printf("\na is GREATER THAN 20\n" ); 76 | 77 | if( b == 20 ) 78 | 79 | { 80 | 81 | /* if condition is true then print the following */ 82 | 83 | printf("\nb is EQUAL TO 20\n" ); 84 | 85 | } 86 | 87 | printf("\nvalue of a is : %d\n", a); 88 | 89 | printf("\nvalue of b is : %d\n", b); 90 | 91 | } 92 | 93 | 94 | 95 | /* check the boolean condition using if statement */ 96 | 97 | /*In this "IF" condition is True therefore the statements/code inside will be Executed Succesfully*/ 98 | 99 | if( a < 20 ) 100 | 101 | { 102 | 103 | /* if condition is true then print the following */ 104 | 105 | printf("\na is LESS THAN 20\n" ); 106 | 107 | if( b == 20 ) 108 | 109 | { 110 | 111 | /* if condition is true then print the following */ 112 | 113 | printf("\nb is EQUAL TO 20\n" ); 114 | 115 | } 116 | 117 | printf("\nvalue of a is : %d\n", a); 118 | 119 | printf("\nvalue of b is : %d\n", b); 120 | 121 | } 122 | 123 | } -------------------------------------------------------------------------------- /NestedIf.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/NestedIf.exe -------------------------------------------------------------------------------- /NestedLoop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/NestedLoop.exe -------------------------------------------------------------------------------- /NestedSwitch.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/NestedSwitch.exe -------------------------------------------------------------------------------- /Null Pointer.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about POINTERS in C Program*/ 2 | 3 | /*Pointer is a type of user defined variable which is used to store the ADDRESS of other variable*/ 4 | 5 | /*pointers are used for dynamic memory allocation ,which is used when we create a dynamic program*/ 6 | 7 | /*In this program Lets see about NULL pointer*/ 8 | 9 | /*Null pointers are initialized when there is no actual variable to assign to the pointer variable*/ 10 | 11 | /*including preprocessor in the program*/ 12 | 13 | #include 14 | 15 | /*creating a main() function of the program*/ 16 | 17 | int main() 18 | 19 | { 20 | 21 | int *ptr; /* pointer variable declaration */ 22 | 23 | ptr = NULL; /* Assigning a NULL pointer*/ 24 | 25 | printf("\nValue stored in variable \"ptr\" : %x\n", ptr ); 26 | 27 | printf("\nAddress of variable \"ptr\" : %x\n", &ptr); 28 | 29 | } -------------------------------------------------------------------------------- /NullPointer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/NullPointer.exe -------------------------------------------------------------------------------- /OperatorsPrecedence.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be Operation Precedence in C it as same as BEDMAS which we use in Math*/ 2 | 3 | /*In C all postfix operation like braces,square bracket, increment , decrement have highgher precedence */ 4 | 5 | /*Then comes the Unary opertors followed by Division,Multiplication,Addition , Subtaraction , Then Shift Operation , Then comes Relatipnal Opeartion, Then Equalities ,All Bitwise Operation,Then comes All logical Operation,Then comes All Assignment Operation*/ 6 | 7 | /*including preprocessor in the program*/ 8 | 9 | #include 10 | 11 | /*creating a main() function of the program*/ 12 | 13 | int main() 14 | 15 | { 16 | 17 | /*Declearing Variable 'a=20' ,Variable 'b=10' ,Variable 'c=15' , Variable 'd=25'and creating a Variable 'e' with no initial value declear*/ 18 | 19 | int a = 20; 20 | 21 | int b = 10; 22 | 23 | int c = 15; 24 | 25 | int d = 25; 26 | 27 | int e; 28 | 29 | e = a + b * c / d ; /* 20 + 10 * 15 / 25 */ 30 | 31 | printf("\nValue of a + b * c / d is e = %d\n", e ); 32 | 33 | e = ( a + b ) * ( c / d ) ; /* ( 20 + 10 ) * ( 15 / 25 ) */ 34 | 35 | printf("\nValue of ( a + b ) * ( c / d ) is e = %d\n", e ); 36 | 37 | e = ( a + b ) * c / d ; /* ( 20 + 10 ) * 15 / 25 */ 38 | 39 | printf("\nValue of ( a + b ) * c / d is e = %d\n", e ); 40 | 41 | e = ( ( a + b ) * c ) / d ; /* ( ( 20 + 10 ) * 15 ) / 25 */ 42 | 43 | printf("\nValue of ( ( a + b ) * c ) / d is e = %d\n", e ); 44 | 45 | e = a + ( b * c / d ) ; /* 20 + ( 10 * 15 / 25 ) */ 46 | 47 | printf("\nValue of a +( b * c / d ) is e = %d\n", e ); 48 | 49 | e = a + ( b * c ) / d ; /* 20 + ( 10 * 15 ) / 25 */ 50 | 51 | printf("\nValue of a + ( b * c ) / d is e = %d\n", e ); 52 | 53 | e = ( a + ( b * c ) ) / d ; /* ( 20 + ( 10 * 15 ) ) / 25 */ 54 | 55 | printf("\nValue of ( a + ( b * c ) ) / d is e = %d\n", e ); 56 | 57 | } 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /OperatorsPrecedence.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/OperatorsPrecedence.exe -------------------------------------------------------------------------------- /Pointer Decrement.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about POINTERS in C Program*/ 2 | 3 | /*Pointer is a type of user defined variable which is used to store the ADDRESS of other variable*/ 4 | 5 | /*pointers are used for dynamic memory allocation ,which is used when we create a dynamic program*/ 6 | 7 | /*In pointer we can able to do certain artimatic operation like increment,decrement...etc,,*/ 8 | 9 | /*In this program lets see about decrementing a pointer in aprogram*/ 10 | 11 | /*including preprocessor in the program*/ 12 | 13 | #include 14 | 15 | /*creating a main() function of the program*/ 16 | 17 | int main() 18 | 19 | { 20 | 21 | int arr[] = {10, 20, 30,40}; 22 | 23 | int i, *ptr; 24 | 25 | /* let us have array address in pointer */ 26 | 27 | ptr = &arr[ 4 - 1 ]; 28 | 29 | for ( i = 4 ; i > 0 ; i-- ) 30 | 31 | { 32 | 33 | printf("\nAddress of arr[%d] = %x\n", i, ptr ); 34 | 35 | printf("\nValue of arr[%d] = %d\n", i, *ptr ); 36 | 37 | /* move to the next location */ 38 | 39 | ptr--; 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /Pointer Increment.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about POINTERS in C Program*/ 2 | 3 | /*Pointer is a type of user defined variable which is used to store the ADDRESS of other variable*/ 4 | 5 | /*pointers are used for dynamic memory allocation ,which is used when we create a dynamic program*/ 6 | 7 | /*In pointer we can able to do certain artimatic operation like increment,decrement...etc,,*/ 8 | 9 | /*In this program lets see about incrementing a pointer in aprogram*/ 10 | 11 | /*including preprocessor in the program*/ 12 | 13 | #include 14 | 15 | /*creating a main() function of the program*/ 16 | 17 | int main() 18 | 19 | { 20 | 21 | int arr[] = {10, 20, 30,40}; 22 | 23 | int i, *ptr; 24 | 25 | /* let us have array address in pointer */ 26 | 27 | ptr = arr; 28 | 29 | for ( i = 0; i < 4; i++) 30 | 31 | { 32 | 33 | printf("\nAddress of arr[%d] = %x\n", i, ptr ); 34 | 35 | printf("\nValue of arr[%d] = %d\n", i, *ptr ); 36 | 37 | /* move to the next location */ 38 | 39 | ptr++; 40 | } 41 | 42 | } -------------------------------------------------------------------------------- /Pointer To Function.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about POINTERS in C Program*/ 2 | 3 | /*Pointer is a type of user defined variable which is used to store the ADDRESS of other variable*/ 4 | 5 | /*pointers are used for dynamic memory allocation ,which is used when we create a dynamic program*/ 6 | 7 | /*In this program lets see about passing a pointer to a function in aprogram*/ 8 | 9 | /*including preprocessor in the program*/ 10 | 11 | #include 12 | 13 | /* function declaration */ 14 | 15 | double Average(int *arr, int size); 16 | 17 | /*creating a main() function of the program*/ 18 | 19 | int main() 20 | 21 | { 22 | 23 | /* an int array with 5 elements */ 24 | 25 | int balance[5] = {10 , 20 , 30 , 40 , 50}; 26 | 27 | double avg; 28 | 29 | /* pass pointer to the array as an argument */ 30 | 31 | avg = Average( balance, 5 ) ; 32 | 33 | /* output the returned value */ 34 | 35 | printf("\nAverage value is: %f\n", avg ); 36 | 37 | } 38 | 39 | double Average(int *arr, int size) 40 | 41 | { 42 | 43 | int i, sum = 0; 44 | 45 | double avg; 46 | 47 | for (i = 0; i < size; ++i) 48 | 49 | { 50 | 51 | sum += arr[i]; 52 | 53 | } 54 | 55 | avg = (double)sum / size; 56 | 57 | return avg; 58 | 59 | } -------------------------------------------------------------------------------- /Pointer To Pointer.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about POINTERS in C Program*/ 2 | 3 | /*Pointer is a type of user defined variable which is used to store the ADDRESS of other variable*/ 4 | 5 | /*pointers are used for dynamic memory allocation ,which is used when we create a dynamic program*/ 6 | 7 | /*Pointer To Pointer is a concept which is used to point one pointer variable to an another pointer variable . That is when a pointer to pointer concept is used, then one pointer points to address of a variable , and that pointer variable is used to point to the address of that pointer variable , which is it is again points to the value of a initial variable*/ 8 | 9 | /*Synatx to declear a Pointer To Pointer Variable 10 | 11 | DataType **var-name; 12 | 13 | */ 14 | 15 | /*including preprocessor in the program*/ 16 | 17 | #include 18 | 19 | /*creating a main() function of the program*/ 20 | 21 | int main() 22 | 23 | { 24 | 25 | int a = 10 ; /* actual variable declaration */ 26 | 27 | int *ptr ; /* pointer variable declaration */ 28 | 29 | int **pptr ; /* pointer to pointer variable declaration */ 30 | 31 | ptr = &a; /* stores the address of "a" in pointer variable "ptr"*/ 32 | 33 | pptr = &ptr; /* stores the address of "ptr" in pointer to pointer variable "pptr"*/ 34 | 35 | printf("\nValue of variable A : %d\n", a ); 36 | 37 | printf("\nAddress of variable A : %x\n", &a ); 38 | 39 | printf("\nValue stored in variable \"ptr\" : %x\n", ptr ); 40 | 41 | printf("\nAddress of variable \"ptr\" : %x\n", &ptr); 42 | 43 | printf("\nThe Variable to which pointer \"ptr\" has been assigned : %x\n", *ptr); 44 | 45 | printf("\nThe value to which pointer \"ptr\" has been assigned : %d\n", *ptr); 46 | 47 | printf("\nValue stored in variable \"pptr\" : %x\n", pptr ); 48 | 49 | printf("\nAddress of variable \"pptr\" : %x\n", &pptr); 50 | 51 | printf("\nThe Variable to which pointer \"pptr\" has been assigned : %x\n", **pptr); 52 | 53 | printf("\nThe value to which pointer \"pptr\" has been assigned : %d\n", **pptr); 54 | 55 | } -------------------------------------------------------------------------------- /Pointer To Structure.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about STRUCTURE in C Program*/ 2 | 3 | /*Structure in C Programming is also know as a user defined Data type which is similar to array.*/ 4 | 5 | /*In Array we can able to store many data of a same data type*/ 6 | 7 | /*In Structure we can able to store many data of various data type*/ 8 | 9 | /*Structure can be accessed using member access operator ( . ) which is also called as DOT operator*/ 10 | 11 | /*Poniters can be passed to a structure in a C program*/ 12 | 13 | /*In this program lets see a passing a pointer to a structure used in C Programming*/ 14 | 15 | /*Synatx to define a structture in c programming 16 | 17 | struct [structure tag] 18 | 19 | { 20 | 21 | member definition; 22 | 23 | member definition; 24 | 25 | ... 26 | 27 | member definition; 28 | 29 | } [one or more structure variables]; 30 | 31 | */ 32 | 33 | /*In pointer to structure we can able to access the member by using -> operator*/ 34 | 35 | /*including preprocessor in the program*/ 36 | 37 | #include 38 | 39 | #include 40 | 41 | /*creating a structure of the program*/ 42 | 43 | struct Student 44 | 45 | { 46 | 47 | char Name[50]; 48 | 49 | int RollNo; 50 | 51 | int MobileNo; 52 | 53 | }; 54 | 55 | /* function declaration */ 56 | 57 | void printStudent( struct Student *student ); 58 | 59 | /*creating a main() function of the program*/ 60 | 61 | int main() 62 | 63 | { 64 | 65 | struct Student student1; 66 | 67 | struct Student student2; 68 | 69 | strcpy(student1.Name, "Maayon"); 70 | 71 | student1.RollNo = 1001001 ; 72 | 73 | student1.MobileNo = 1010101010 ; 74 | 75 | strcpy(student2.Name, "Tech Guru"); 76 | 77 | student2.RollNo = 1011011 ; 78 | 79 | student2.MobileNo = 1212121212 ; 80 | 81 | printStudent ( &student1 ); 82 | 83 | printStudent ( &student2 ); 84 | 85 | } 86 | 87 | 88 | void printStudent( struct Student *student ) 89 | 90 | { 91 | 92 | printf("\nThe student Name is : %s\n",student->Name); 93 | 94 | printf("\nThe student RollNo is : %d\n",student->RollNo); 95 | 96 | printf("\nThe student MobileNo is : %d\n",student->MobileNo); 97 | 98 | } -------------------------------------------------------------------------------- /Pointer.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about POINTERS in C Program*/ 2 | 3 | /*Pointer is a type of user defined variable which is used to store the ADDRESS of other variable*/ 4 | 5 | /*pointers are used for dynamic memory allocation ,which is used when we create a dynamic program*/ 6 | 7 | /*Synatx to declear a Pointer Variable 8 | 9 | DataType *var-name; 10 | 11 | */ 12 | 13 | /*including preprocessor in the program*/ 14 | 15 | #include 16 | 17 | /*creating a main() function of the program*/ 18 | 19 | int main() 20 | 21 | { 22 | 23 | int a = 10; /* actual variable declaration */ 24 | 25 | int *ptr; /* pointer variable declaration */ 26 | 27 | ptr = &a; /* stores the address of "a" in pointer variable "ptr"*/ 28 | 29 | printf("\nValue of variable A : %d\n", a ); 30 | 31 | printf("\nAddress of variable A : %x\n", &a ); 32 | 33 | printf("\nValue stored in variable \"ptr\" : %x\n", ptr ); 34 | 35 | printf("\nAddress of variable \"ptr\" : %x\n", &ptr); 36 | 37 | printf("\nThe Variable to which pointer \"ptr\" has been assigned : %x\n", *ptr); 38 | 39 | printf("\nThe value to which pointer \"ptr\" has been assigned : %d\n", *ptr); 40 | 41 | } -------------------------------------------------------------------------------- /PointerDecrement.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/PointerDecrement.exe -------------------------------------------------------------------------------- /PointerToFunction.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/PointerToFunction.exe -------------------------------------------------------------------------------- /PointerToPointer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/PointerToPointer.exe -------------------------------------------------------------------------------- /PointerToStructure.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/PointerToStructure.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Complete-C-Programming 2 | 3 | This is a complete C programming tutorial where you can learn all concepts in C programming Language. 4 | 5 | Before going directly into the code, have a look at README.md file and follow it .To make this tutorial useful. 6 | 7 | ## Introduction: 8 | 9 | + C was developed by Dennis Ritchie 10 | 11 | ### Why C Programmig? 12 | 13 | + Highly portable. 14 | + Execute faster. 15 | + General performance. 16 | + Easy to learn 17 | 18 | ### What C Programming? 19 | 20 | + Mother Language = Base for other languages. 21 | + System Programming Language = Used to do Low-level programming. 22 | + Procedure-Oriented = Series of steps, functions, method. 23 | + Structured Language = parts or blocks. 24 | 25 | ### Where C Programming? 26 | + Operating system. 27 | + Assemblers. 28 | + Database. 29 | + Network. 30 | + Compiler Design. 31 | 32 | ## Compiler Installation: 33 | 34 | MinGW = [https://sourceforge.net/projects/mingw/](https://sourceforge.net/projects/mingw/) 35 | 36 |

37 | 38 | 39 | 40 |

41 | 42 |

43 | 44 | 45 | 46 |

47 | 48 |

49 | 50 | 51 | 52 |

53 | 54 |

55 | 56 | 57 | 58 |

59 | 60 | 61 |

62 | 63 | 64 | 65 |

66 | 67 |

68 | 69 | 70 | 71 |

72 | 73 |

74 | 75 | 76 | 77 |

78 | 79 |

80 | 81 | 82 | 83 |

84 | 85 |

86 | 87 | 88 | 89 |

90 | 91 |

92 | 93 | 94 | 95 |

96 | 97 |

98 | 99 | 100 | 101 |

102 | 103 |

104 | 105 | 106 | 107 |

108 | 109 |

110 | 111 | 112 | 113 |

114 | 115 |

116 | 117 | 118 | 119 |

120 | 121 |

122 | 123 | 124 | 125 |

126 | 127 |

128 | 129 | 130 | 131 |

132 | 133 |

134 | 135 | 136 | 137 |

138 | 139 |

140 | 141 | 142 | 143 |

144 | 145 |

146 | 147 | 148 | 149 |

150 | 151 |

152 | 153 | 154 | 155 |

156 | 157 |

158 | 159 | 160 | 161 |

162 | 163 |

164 | 165 | 166 | 167 |

168 | 169 |

170 | 171 | 172 | 173 |

174 | 175 |

176 | 177 | 178 | 179 |

180 | 181 |

182 | 183 | 184 | 185 |

186 | 187 |

188 | 189 | 190 | 191 |

192 | 193 | ## Structure of C Programming: 194 | 195 | #include /headerfile. 196 | 197 | void main() /main function. 198 | 199 | { /block start. 200 | 201 | printf("This is Ajay"); /statement. 202 | 203 | } /block end. 204 | 205 | ## Compling the C Program: 206 | 207 |

208 | 209 | 210 | 211 |

212 | 213 | ## Programs: 214 | 215 | 1. [simple C Program](https://github.com/maayon2521/Complete-C-Programming/blob/master/SimpleCProgram.c) - In this simple C Program, its structure and working will be explained. 216 | 217 | 2. [Data Type](https://github.com/maayon2521/Complete-C-Programming/blob/master/DataType.c) - In this major Data Type available in C Program has been explained. 218 | 219 | 3. [Variable](https://github.com/maayon2521/Complete-C-Programming/blob/master/Variable.c) - In this concept of variable has been explained. 220 | 221 | 4. [Escape Sequence](https://github.com/maayon2521/Complete-C-Programming/blob/master/EscapeSequence.c) - In this major special characters or escape sequence which is available in C Program has been explained 222 | 223 | 5. [Arithemetic Operation](https://github.com/maayon2521/Complete-C-Programming/blob/master/ArithmeticOperation.c) - In this Arithmetic Operation available in C Program has been explained. 224 | 225 | 6. [Relational Operation](https://github.com/maayon2521/Complete-C-Programming/blob/master/RelationalOperation.c) - In this Relational Operation available in C Program has been explained. 226 | 227 | 7. [Logical Operation](https://github.com/maayon2521/Complete-C-Programming/blob/master/LogicalOperation.c) - In this Logical Operation available in C Program has been explained. 228 | 229 | 8. [Assignment Operation](https://github.com/maayon2521/Complete-C-Programming/blob/master/AssignmentOperation.c) - In this Assignment Operation available in C Program has been explained. 230 | 231 | 9. [Misc Operation](https://github.com/maayon2521/Complete-C-Programming/blob/master/MiscOperation.c) - In this Misc Operation avaliable in C Program has been explained. 232 | 233 | 10. [Operation Precedence](https://github.com/maayon2521/Complete-C-Programming/blob/master/OperatorsPrecedence.c) - In this how the operations are performed in an order is explained. 234 | 235 | 11. [if](https://github.com/maayon2521/Complete-C-Programming/blob/master/SimpleIF.c) - In this If Statement in C Program has been explained. 236 | 237 | 12. [if else](https://github.com/maayon2521/Complete-C-Programming/blob/master/if%20else.c) - In this If else Statement in C Program has been explained. 238 | 239 | 13. [if else if](https://github.com/maayon2521/Complete-C-Programming/blob/master/if%20else%20if.c) - In this If else if Statement in C Program has been explained. 240 | 241 | 14. [Nested if](https://github.com/maayon2521/Complete-C-Programming/blob/master/Nested%20if.c) - In this Nested if statement in C Program has been explained. 242 | 243 | 15. [switch](https://github.com/maayon2521/Complete-C-Programming/blob/master/Switch.c) - In this Switch statement in C Program has been explained. 244 | 245 | 16. [Nested Switch](https://github.com/maayon2521/Complete-C-Programming/blob/master/Nested%20Switch.c) - In this Nested Switch statement in C Program has been explained. 246 | 247 | 17. [break](https://github.com/maayon2521/Complete-C-Programming/blob/master/Break.c) - In this "break" control statement in C Program has been explained. 248 | 249 | 18. [continue](https://github.com/maayon2521/Complete-C-Programming/blob/master/Continue.c) - In this "continue" control statement in C Program has been explained. 250 | 251 | 19. [goto](https://github.com/maayon2521/Complete-C-Programming/blob/master/goto.c) - In this "goto" control statement in C Program has been explained. 252 | 253 | 20. [while Loop](https://github.com/maayon2521/Complete-C-Programming/blob/master/While%20Loop.c) - In this While loop concept in C Program has been explained. 254 | 255 | 21. [for Loop](https://github.com/maayon2521/Complete-C-Programming/blob/master/For%20Loop.c) - In this for loop concept in C Program has been explained. 256 | 257 | 22. [do while Loop](https://github.com/maayon2521/Complete-C-Programming/blob/master/Do%20While%20Loop.c) - In this do while loop concept in C Program has been explained. 258 | 259 | 23. [nested Loop](https://github.com/maayon2521/Complete-C-Programming/blob/master/Nested%20Loop.c) - In this nested loop concept in C Program has been explained. 260 | 261 | 24. [infinite Loop](https://github.com/maayon2521/Complete-C-Programming/blob/master/Infinite%20Loop.c) - In this infinite loop concept in C Program has been explained. 262 | 263 | 25. [Function](https://github.com/maayon2521/Complete-C-Programming/blob/master/Function.c) - In this function concept in C Program has been explained. 264 | 265 | 26. [Call by Value](https://github.com/maayon2521/Complete-C-Programming/blob/master/Call%20By%20Value.c) - In this Call by Value method in C Program has been explained. 266 | 267 | 27. [Call by Reference](https://github.com/maayon2521/Complete-C-Programming/blob/master/Call%20By%20Reference.c) - In this call by Reference method in C Program has been explained. 268 | 269 | 28. [Scope Rule](https://github.com/maayon2521/Complete-C-Programming/blob/master/Scope%20Rule.c) - In this Scope Rule to be followed has been explained. 270 | 271 | 29. [Array](https://github.com/maayon2521/Complete-C-Programming/blob/master/Array.c) - In this Array concept in C Program has been explained. 272 | 273 | 30. [Multi Dimensional Array](https://github.com/maayon2521/Complete-C-Programming/blob/master/Multi%20Dim%20Array.c) - In this multi Dimensional Array concept has been explained by using Two Dimensional Array. 274 | 275 | 31. [Pointer](https://github.com/maayon2521/Complete-C-Programming/blob/master/Pointer.c) - In this pointer concept in C Program has been explained. 276 | 277 | 32. [Null Pointer](https://github.com/maayon2521/Complete-C-Programming/blob/master/Null%20Pointer.c) - In this Null pointer concept in C Program has been explained. 278 | 279 | 33. [Pointer Increment](https://github.com/maayon2521/Complete-C-Programming/blob/master/Pointer%20Increment.c) - In this pointer Increment in C Program has been explained. 280 | 281 | 34. [Pointer Decrement](https://github.com/maayon2521/Complete-C-Programming/blob/master/Pointer%20Decrement.c) - In this pointer decrement in C Program has been explained. 282 | 283 | 35. [Array of Pointer](https://github.com/maayon2521/Complete-C-Programming/blob/master/Array%20Of%20Pointer.c) - In this Array of pointer concept in C Program has been explained. 284 | 285 | 36. [Pointer to Pointer](https://github.com/maayon2521/Complete-C-Programming/blob/master/Pointer%20To%20Pointer.c) - In this pointer to pointer concept in C Program has been explained. 286 | 287 | 37. [Pointer to Function](https://github.com/maayon2521/Complete-C-Programming/blob/master/Pointer%20To%20Function.c) - In this pointer to function concept in C Program has been explained. 288 | 289 | 38. [String](https://github.com/maayon2521/Complete-C-Programming/blob/master/String.c) - In this string concept and major string function in C Program has been explained. 290 | 291 | 39. [Structure](https://github.com/maayon2521/Complete-C-Programming/blob/master/Structure.c) - In this structure concept in C Program has been explained. 292 | 293 | 40. [Structure to Function](https://github.com/maayon2521/Complete-C-Programming/blob/master/Structure%20To%20Function.c) - In this structure to function concept in C Program has been explained. 294 | 295 | 41. [Pointer to Structure](https://github.com/maayon2521/Complete-C-Programming/blob/master/Pointer%20To%20Structure.c) - In this Pointer to Structure concept in C Program has been explained. 296 | 297 | 42. [Union](https://github.com/maayon2521/Complete-C-Programming/blob/master/Union.c) - In this union concept in C Program has been explained. 298 | 299 | 43. [Typedef](https://github.com/maayon2521/Complete-C-Programming/blob/master/TypeDef.c) - In this Typedef concept in C Program has been explained. 300 | 301 | 44. [Typedef in Structure](https://github.com/maayon2521/Complete-C-Programming/blob/master/Typedef%20in%20Structure.c) - In this Typedef concept in C Program has been explained by using Structure. 302 | 303 | 45. [#define](https://github.com/maayon2521/Complete-C-Programming/blob/master/%23define.c) - In this #define concept in C Program has been explained. 304 | 305 | 46. [getchar putchar](https://github.com/maayon2521/Complete-C-Programming/blob/master/getchar%20%26%20putchar.c) - In this Input and output in C Program has been explained using getchar() and putchar(). 306 | 307 | 47. [gets puts](https://github.com/maayon2521/Complete-C-Programming/blob/master/gets%20puts.c) - In this Input and output in C Program has been explained using gets() and puts(). 308 | 309 | 48. [scanf printf](https://github.com/maayon2521/Complete-C-Programming/blob/master/if%20else.c) - In this Input and output in C Program has been explained using scanf() and printf(). 310 | 311 | 49. [Write File](https://github.com/maayon2521/Complete-C-Programming/blob/master/Write%20File.c) - In this File concept in C Program has been explained using writing into a file. 312 | 313 | 50. [Read File](https://github.com/maayon2521/Complete-C-Programming/blob/master/Read%20File.c) - In this File concept in C Program has been explained using reading from a file. 314 | 315 | 51. [Typecast](https://github.com/maayon2521/Complete-C-Programming/blob/master/Typecast.c) - In this Typecasting a variable concept in C Program has been explained. 316 | 317 | 52. [Error Handling](https://github.com/maayon2521/Complete-C-Programming/blob/master/Error%20Handling.c) - In this Error Handling concept in C Program has been explained. 318 | 319 | 53. [Recursion](https://github.com/maayon2521/Complete-C-Programming/blob/master/Recursion.c) - In this Recursion concept in C Program has been explained. 320 | 321 | 54. [Malloc](https://github.com/maayon2521/Complete-C-Programming/blob/master/Malloc.c) - In this Memory Management concept in C Program has been explained using malloc(). 322 | 323 | 55. [calloc](https://github.com/maayon2521/Complete-C-Programming/blob/master/Calloc.c) - In this Memory Management concept in C Program has been explained using calloc(). 324 | 325 | 56. [realloc free](https://github.com/maayon2521/Complete-C-Programming/blob/master/Realloc%20Free.c) - In this Memory Management concept in C Program has been explained using realloc() and free(). 326 | 327 | 57. [Command Line](https://github.com/maayon2521/Complete-C-Programming/blob/master/Command%20Line.c) - In this Command Line Argument concept in C Program has been explained. 328 | 329 | 330 | THANKS A LOT FOR READING . 331 | 332 | IF YOU HAVE ANY QUERIES OR SUGGESTIONS, PLEASE MAIL ME AT "ajayajutheaj@gmail.com". 333 | -------------------------------------------------------------------------------- /Read File.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about FILES in C Program*/ 2 | 3 | /*In this program let see how to open or write in a txt file in c program.*/ 4 | 5 | /*fopen() is a function used to open a file or create a file in c program*/ 6 | 7 | /*fclose() is a function used to close a file in c program*/ 8 | 9 | /*synatx for fopen() 10 | 11 | FILE *fopen( const char * filename, const char * mode ); 12 | 13 | */ 14 | 15 | /*filename is the name of the file*/ 16 | 17 | /*mode is in which mode the file is used*/ 18 | 19 | /*There are 6 types of mode to read files. They are*/ 20 | 21 | /* 1 - 'r' = open in read only mode.*/ 22 | 23 | /* 2 - 'w' = open in write only mode.*/ 24 | 25 | /* 3 - 'a' = open in append only mode.*/ 26 | 27 | /* 4 - 'r+' = open in both read and write mode.*/ 28 | 29 | /* 5 - 'w+' = open in read and write mode.*/ 30 | 31 | /* 6 - 'a+' = open in read and write mode.Reading is done from beginning and write can only be appended*/ 32 | 33 | /*In this program let see about how to read a file*/ 34 | 35 | /*synatx for reading from file is 36 | 37 | fgets( char *buf , int n, FILE *fp); 38 | 39 | */ 40 | 41 | /*including preprocessor in the program*/ 42 | 43 | #include 44 | 45 | /*creating a main() function of the program*/ 46 | 47 | void main() 48 | 49 | { 50 | 51 | char buffer[500]; 52 | 53 | /*opening file in read mode*/ 54 | 55 | FILE *fileptr = fopen("C:/Users/MAAYON/Desktop/c/Maayon.txt", "r"); 56 | 57 | /*reading using fgets()*/ 58 | 59 | printf("\n"); 60 | 61 | while ( fgets(buffer, 500, fileptr) != NULL) 62 | 63 | { 64 | 65 | printf("%s\n", buffer); 66 | 67 | } 68 | 69 | fclose(fileptr); 70 | 71 | } -------------------------------------------------------------------------------- /ReadFile.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ReadFile.exe -------------------------------------------------------------------------------- /Realloc Free.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about Memory Managemet in C Program*/ 2 | 3 | /*In C Program memory can be managed easy by using dynamic memory allocation */ 4 | 5 | /*In this program lets see a realloc() and free() used in C Programming*/ 6 | 7 | /*And lets see how to re-allocate memory in dynamic manner*/ 8 | 9 | /*And how to free the memory which is allocated dynammically*/ 10 | 11 | /*Synatx to define a realloc() in c programming 12 | 13 | void *realloc(void *address , int newsize); 14 | 15 | */ 16 | 17 | /*Synatx to define a free() in c programming 18 | 19 | void free(void *address ); 20 | 21 | */ 22 | 23 | /*including preprocessor in the program*/ 24 | 25 | #include 26 | 27 | #include 28 | 29 | #include 30 | 31 | int main() 32 | 33 | { 34 | 35 | char name[100]; 36 | 37 | /* allocate memory dynamically */ 38 | 39 | char *work; 40 | 41 | strcpy(name, "Mayyon"); 42 | 43 | work = malloc( 30 * sizeof(char) ); 44 | 45 | if( work == NULL ) 46 | 47 | { 48 | 49 | fprintf(stderr, "Error - unable to allocate required memory\n"); 50 | 51 | } 52 | 53 | else 54 | 55 | { 56 | 57 | strcpy( work, "Maayon is a poet . "); 58 | 59 | } 60 | 61 | /* reallocating the memory*/ 62 | 63 | work = realloc( work , 100 * sizeof(char) ); 64 | 65 | if( work == NULL ) 66 | 67 | { 68 | 69 | fprintf(stderr, "Error - unable to allocate required memory\n"); 70 | 71 | } 72 | 73 | else 74 | 75 | { 76 | 77 | strcpy( work, "He own's a page in instagram called Maaya_kavi ."); 78 | 79 | } 80 | 81 | printf("\nName = %s\n", name ); 82 | 83 | printf("\nWork : %s\n", work ); 84 | 85 | /*freeing memory */ 86 | 87 | free ( work ); 88 | 89 | } -------------------------------------------------------------------------------- /ReallocFree.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ReallocFree.exe -------------------------------------------------------------------------------- /Recursion.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about RECURSION in C Program*/ 2 | 3 | /*Recursion is process of calling a function inside the same function. That is the process of repeating utem in a self similar way in c program*/ 4 | 5 | /*Syntax of Recursion in c program is 6 | 7 | void recursion() 8 | 9 | { 10 | 11 | recursion(); 12 | 13 | } 14 | 15 | */ 16 | 17 | /*let see recursion by finding a factorial for a number */ 18 | 19 | /*including preprocessor in the program*/ 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | /*declearing a function factorial()*/ 28 | 29 | int factorial(int i); 30 | 31 | /*creating a main() function of the program*/ 32 | 33 | int main() 34 | 35 | { 36 | 37 | int i = 3 ; 38 | 39 | printf("\nFactorial of %d is %d\n", i, factorial(i)); 40 | 41 | return 0; 42 | 43 | } 44 | 45 | int factorial(int i) 46 | 47 | { 48 | 49 | if(i <= 1) 50 | 51 | { 52 | 53 | return 1; 54 | 55 | } 56 | 57 | return i * factorial(i - 1); 58 | 59 | } -------------------------------------------------------------------------------- /Recursion.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Recursion.exe -------------------------------------------------------------------------------- /RelationalOperation.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing all the Relational Operators like equal , unequal, lesser than , lesser than or equal to , greater than , greater than or equal to etc.. avaliable in C*/ 2 | 3 | /*including preprocessor in the program*/ 4 | 5 | #include 6 | 7 | /*creating a main() function of the program*/ 8 | 9 | int main() 10 | 11 | { 12 | 13 | /*Declearing Variable 'a=10' Variable 'b=20' and creating a Variable 'c' with no initial value declear*/ 14 | 15 | int a = 10; 16 | 17 | int b = 20; 18 | 19 | int c ; 20 | 21 | /*Here I have used a concept of if and if-else , Don't worry about it , i will be covering in the if and if else concept later on*/ 22 | 23 | /* Now checking for EQUAL TO condition that if a and b contains an equal or same value then it pass the condition else it will not pass the condition*/ 24 | 25 | if( a == b ) 26 | 27 | { 28 | 29 | printf("\na is equal to b and EQUAL TO condition is Passed.\n" ); 30 | 31 | } 32 | 33 | else 34 | 35 | { 36 | 37 | printf("\na is not equal to b and EQUAL TO condition is Not-Passed.\n" ); 38 | 39 | } 40 | 41 | /* Now checking for NOT EQUAL TO condition that if a and b contains an non equal or different value then it pass the condition else it will not pass the condition*/ 42 | 43 | if( a != b ) 44 | 45 | { 46 | 47 | printf("\na is not equal to b and NOT EQUAL TO condition is Passed.\n" ); 48 | 49 | } 50 | 51 | else 52 | 53 | { 54 | 55 | printf("\na is equal to b and NOT EQUAL TO condition is Not-Passed.\n" ); 56 | 57 | } 58 | 59 | /* Now checking for LESSER THAN condtion that if 'a' contains a value lesser then 'b' then it pass the condition else it will not pass the condition*/ 60 | 61 | if ( a < b ) 62 | 63 | { 64 | 65 | printf("\na is less than b and LESSER THAN condition is Passed.\n" ); 66 | 67 | } 68 | 69 | else 70 | 71 | { 72 | 73 | printf("\na is not less than b and LESSER THAN condition is Not-Passed.\n" ); 74 | 75 | } 76 | 77 | /* Now checking for GREATER THAN condtion that if 'a' contains a value greater then 'b' then it pass the condition else it will not pass the condition*/ 78 | 79 | if ( a > b ) 80 | 81 | { 82 | 83 | printf("\na is greater than b and GREATER THAN condition is Passed.\n" ); 84 | 85 | } 86 | 87 | else 88 | 89 | { 90 | 91 | printf("\na is not greater than b and GREATER THAN condition is Not-Passed.\n" ); 92 | 93 | } 94 | 95 | /* Now checking for LESSER THAN or EQUAL TO condtion that if 'a' contains a value lesser then 'b' or Equal to the value of 'b' then it pass the condition else it will not pass the condition*/ 96 | 97 | if ( a <= b ) 98 | 99 | { 100 | 101 | printf("\na is either less than or equal to b and LESSER THAN or EQUAL TO condition is Passed. \n" ); 102 | 103 | } 104 | 105 | else 106 | 107 | { 108 | 109 | printf("\na is either Not less than or Not equal to b and LESSER THAN or EQUAL TO condition is Not-Passed. \n" ); 110 | 111 | } 112 | 113 | /* Now checking for GREATER THAN or EQUAL TO condtion that if 'a' contains a value greater then 'b' or Equal to the value of 'b' then it pass the condition else it will not pass the condition*/ 114 | 115 | if ( a >= b ) 116 | 117 | { 118 | 119 | printf("\nb is either greater than or equal to b and GREATER THAN or EQUAL TO condition is Passed. \n" ); 120 | 121 | } 122 | 123 | else 124 | 125 | { 126 | 127 | printf("\na is either Not great than or Not equal to b and GREATER THAN or EQUAL TO condition is Not-Passed. \n" ); 128 | 129 | } 130 | 131 | } -------------------------------------------------------------------------------- /RelationalOperation.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/RelationalOperation.exe -------------------------------------------------------------------------------- /Scope Rule.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about SCOPE RULE in C Program*/ 2 | 3 | /*Scope rule is rule which is used for defining or declearing a variable inside a C Program*/ 4 | 5 | /*In C program a variable cane defined or decleared in this 3 places such as, inside the function,outside the function and as a formal parameter*/ 6 | 7 | /*Inside the function is called as "LOCAL VARIABLE"*/ 8 | 9 | /*Outside the function is called as "GOBAL VARIABLE"*/ 10 | 11 | /*As a definition of function is called as "FORMAL PARAMETRS"*/ 12 | 13 | /*including preprocessor in the program*/ 14 | 15 | #include 16 | 17 | /*Declearing A as a GOBAL VARIABLE*/ 18 | 19 | int a = 20; 20 | 21 | /*creating a user defined function called add()*/ 22 | 23 | int add( int x , int y ) /* int x , int y is a parameter list which is passed in the function add , is called as FORMAL PARAMETER*/ 24 | 25 | { 26 | 27 | /*function body which is used to add two numbers*/ 28 | 29 | /*Declearing LOCAL VARIABLE of function add()*/ 30 | 31 | int sum; 32 | 33 | sum = x +y ; 34 | 35 | return sum ; 36 | 37 | } 38 | 39 | /*creating a main() function of the program*/ 40 | 41 | int main() 42 | 43 | { 44 | 45 | printf("\nThe Value of Gobal Variable is : %d \n",a); 46 | 47 | /*Declearing LOCAL VARIABLE of function main()*/ 48 | 49 | int a = 10 ; 50 | 51 | int b = 20; 52 | 53 | int sum; 54 | 55 | printf("\nThe Value of LOCAl Variable A is : %d \n",a); 56 | 57 | printf("\nThe Value of LOCAL Variable B is : %d \n",b); 58 | 59 | sum = add ( a , b ); /*calling the function add into the main program*/ 60 | 61 | printf("\nThe addition of value %d and % d is : %d\n", a , b , sum); 62 | 63 | } -------------------------------------------------------------------------------- /ScopeRule.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ScopeRule.exe -------------------------------------------------------------------------------- /SimpleCProgram.c: -------------------------------------------------------------------------------- 1 | /*Note any statement which is present inside a black slash followed by Astrix symbol then it is called as Comments which will be ignored by C complier while compling the C program source code*/ 2 | 3 | /*the first line of the program consist of preprocessor commands which is used to inculde a pre-defined funcctions avaliable in c progarmming which is needed to built the c program*/ 4 | 5 | #include 6 | 7 | /*then we create create the fuction where statements and codes will be present and which will be working when the program is compiled*/ 8 | 9 | /*Note: A C program must contain atleast one main () function in a entier C program*/ 10 | 11 | int main() 12 | { 13 | 14 | /* printf is standard per defined function which is used to print the statement which is present inside the double quotes */ 15 | printf("Hello, Its is an Simple C program.!"); 16 | 17 | /*return will be used is return the value of a function , it was an optional one */ 18 | 19 | return 0; 20 | } -------------------------------------------------------------------------------- /SimpleCProgram.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/SimpleCProgram.exe -------------------------------------------------------------------------------- /SimpleIF.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing Decision Making Statements*/ 2 | 3 | /*In C if, if else, nested if , switch , nested Switch are know as Decision Making Statements , which is used to have decision based up on the condition , the statement is executed*/ 4 | 5 | /*In this Example lets see how SIMPLE IF Statement works in a program*/ 6 | 7 | /*Syntax of Simple If statement 8 | 9 | if(boolean_expression) 10 | 11 | { 12 | 13 | statement 1; 14 | 15 | statement 2; 16 | 17 | . 18 | . 19 | . 20 | 21 | statement n; 22 | 23 | } 24 | */ 25 | 26 | /*including preprocessor in the program*/ 27 | 28 | #include 29 | 30 | /*creating a main() function of the program*/ 31 | 32 | int main() 33 | 34 | { 35 | 36 | /* local variable definition */ 37 | 38 | int a = 10; 39 | 40 | /* check the boolean condition using if statement */ 41 | 42 | /*In this "IF" condition is True therefore the statements/code inside will be Executed Succesfully*/ 43 | 44 | if( a < 20 ) 45 | 46 | { 47 | 48 | /* if condition is true then print the following */ 49 | 50 | printf("\na is less than 20\n" ); 51 | 52 | } 53 | 54 | printf("\nvalue of a is : %d\n", a); 55 | 56 | /* check the boolean condition using if statement */ 57 | 58 | /*In this "IF" condition is False therefore the statements/code inside will be NOT-Execute*/ 59 | 60 | if( a > 20 ) 61 | 62 | { 63 | 64 | printf("\na is Greater than 20\n" ); 65 | 66 | } 67 | 68 | printf("\nvalue of a is : %d\n", a); 69 | 70 | } -------------------------------------------------------------------------------- /SimpleIF.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/SimpleIF.exe -------------------------------------------------------------------------------- /String.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about STRING in C Program*/ 2 | 3 | /*Strings in C Programming is also know as a One Dimensional Array of characters. Thus string contains a character Array which is terminated by a null character "\0"*/ 4 | 5 | /*By Default C compiler initialize a Null character at the end of every String . Therefore no woriies about the null character . Just have a note on it.*/ 6 | 7 | /*In this program lets see some string functons used in C Programming*/ 8 | 9 | /*including preprocessor in the program*/ 10 | 11 | #include 12 | 13 | #include /*String.h is a predifined preprossor used to work with Strings in C Program*/ 14 | 15 | /*creating a main() function of the program*/ 16 | 17 | int main() 18 | 19 | { 20 | 21 | char str1[20] = "String"; 22 | 23 | char str2[20] = "Program"; 24 | 25 | char str3[20]; 26 | 27 | char str4[20] = "Strings"; 28 | 29 | /*strlen() is an perdefined function which is used find the length of the String */ 30 | 31 | /*Synatx for strcat() is 32 | 33 | strlen( String Variable ); 34 | 35 | */ 36 | 37 | printf("\nThe length of the String 1 \"%s\" is ::: %d\n", str1 , strlen(str1) ); 38 | 39 | printf("\nThe length of the String 2 \"%s\" is ::: %d\n", str1 , strlen(str2) ); 40 | 41 | printf("\nThe length of the String 4 \"%s\" is ::: %d\n", str4 , strlen(str4) ); 42 | 43 | /*strcpy() is an perdefined function which is used copy a source String to the Destination String */ 44 | 45 | /*Synatx for strcpy() is 46 | 47 | strcpy( Destination String Variable , Source String Variable ) ; 48 | 49 | */ 50 | 51 | strcpy(str3, str1); 52 | 53 | printf("\nThe value which is copied to str3 from str1 is ::: %s\n", str3 ); 54 | 55 | /*strcpy() is an perdefined function which is used concatenates two strings together and place it at the end of first string variable*/ 56 | 57 | /*Synatx for strcat() is 58 | 59 | strcat( String Variable 1 , String Variable 2 ) ; 60 | 61 | */ 62 | 63 | strcat( str1, str2); 64 | 65 | printf("\nThe concatenates the two strings is ::: %s\n", str1 ); 66 | 67 | /*strchr() is an perdefined function which is used find the first occurrence of that character in a String */ 68 | 69 | /*Synatx for strchr() is 70 | 71 | strlen( String Variable , 'character to be find' ) ; 72 | 73 | */ 74 | 75 | printf("\nThe first occurence of the finding character in String 1 \"%s\" is from ::: %s\n", str1 , strchr( str1 , 'g' ) ); 76 | 77 | /*strcmp() is an perdefined function which is used compare two strings , is the two string are same then it returns 0 , if first string is greater then second string then it return a value greater than 0, if first string is lesser then second string then it return a value lesser than 0*/ 78 | 79 | /*Synatx for strcmp() is 80 | 81 | strlen( String Variable 1 , String Variable 2 ) ; 82 | 83 | */ 84 | 85 | if ( strcmp( str3 , str4) == 0 ) 86 | 87 | { 88 | 89 | printf("\nSince str3 and str4 is same which returns ZERO.Thus if statement is executed.\n"); 90 | 91 | } 92 | 93 | else if ( strcmp( str3 , str4) < 0 ) 94 | 95 | { 96 | 97 | printf("\nSince str3 and str4 is not same and str3 is lesser than ZERO which returns a value Lesser than ZERO.Thus else if statement is executed.\n"); 98 | 99 | } 100 | 101 | else 102 | 103 | { 104 | 105 | printf("\nSince str3 and str4 is not same and str3 is Greater than ZERO which returns a value Greater than ZERO.Thus else statement is executed.\n"); 106 | 107 | } 108 | 109 | /*strstr() is predefined function in string which is used for finding a occurance of one string in onther string, also know as substring finding*/ 110 | 111 | /*synatx for strstr() 112 | 113 | strstr( string which is to be examined , string which we gonna found in examine string); 114 | 115 | */ 116 | 117 | char *strF; 118 | 119 | strF = strstr( str1 , str3); 120 | 121 | if (strF) 122 | 123 | { 124 | 125 | printf("\nThe Sub String of str2 is FOUND in str1.\n"); 126 | 127 | } 128 | 129 | else 130 | 131 | { 132 | 133 | printf("\nThe Sub String of str2 is NOT FOUND in str1.\n"); 134 | 135 | } 136 | 137 | } -------------------------------------------------------------------------------- /String.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/String.exe -------------------------------------------------------------------------------- /Structure To Function.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about STRUCTURE in C Program*/ 2 | 3 | /*Structure in C Programming is also know as a user defined Data type which is similar to array.*/ 4 | 5 | /*In Array we can able to store many data of a same data type*/ 6 | 7 | /*In Structure we can able to store many data of various data type*/ 8 | 9 | /*Structure can be accessed using member access operator ( . ) which is also called as DOT operator*/ 10 | 11 | /*Structure can be passed to function as same how a variable or pointer is passed to a function*/ 12 | 13 | /*In this program lets see a passing a structure to a function used in C Programming*/ 14 | 15 | /*Synatx to define a structture in c programming 16 | 17 | struct [structure tag] 18 | 19 | { 20 | 21 | member definition; 22 | 23 | member definition; 24 | 25 | ... 26 | 27 | member definition; 28 | 29 | } [one or more structure variables]; 30 | 31 | */ 32 | 33 | 34 | /*including preprocessor in the program*/ 35 | 36 | #include 37 | 38 | #include 39 | 40 | /*creating a structure of the program*/ 41 | 42 | struct Student 43 | 44 | { 45 | 46 | char Name[50]; 47 | 48 | int RollNo; 49 | 50 | int MobileNo; 51 | 52 | }; 53 | 54 | /* function declaration */ 55 | 56 | void printStudent( struct Student student ); 57 | 58 | /*creating a main() function of the program*/ 59 | 60 | int main() 61 | 62 | { 63 | 64 | struct Student student1; 65 | 66 | struct Student student2; 67 | 68 | strcpy(student1.Name, "Maayon"); 69 | 70 | student1.RollNo = 1001001 ; 71 | 72 | student1.MobileNo = 1010101010 ; 73 | 74 | strcpy(student2.Name, "Tech Guru"); 75 | 76 | student2.RollNo = 1011011 ; 77 | 78 | student2.MobileNo = 1212121212 ; 79 | 80 | printStudent ( student1 ); 81 | 82 | printStudent ( student2 ); 83 | 84 | } 85 | 86 | 87 | void printStudent( struct Student student ) 88 | 89 | { 90 | 91 | printf("\nThe student Name is : %s\n",student.Name); 92 | 93 | printf("\nThe student RollNo is : %d\n",student.RollNo); 94 | 95 | printf("\nThe student MobileNo is : %d\n",student.MobileNo); 96 | 97 | } -------------------------------------------------------------------------------- /Structure.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about STRUCTURE in C Program*/ 2 | 3 | /*Structure in C Programming is also know as a user defined Data type which is similar to array.*/ 4 | 5 | /*In Array we can able to store many data of a same data type*/ 6 | 7 | /*In Structure we can able to store many data of various data type*/ 8 | 9 | /*Structure can be accessed using member access operator ( . ) which is also called as DOT operator*/ 10 | 11 | /*In this program lets see a simple structure used in C Programming*/ 12 | 13 | /*Synatx to define a structture in c programming 14 | 15 | struct [structure tag] 16 | 17 | { 18 | 19 | member definition; 20 | 21 | member definition; 22 | 23 | ... 24 | 25 | member definition; 26 | 27 | } [one or more structure variables]; 28 | 29 | */ 30 | 31 | 32 | /*including preprocessor in the program*/ 33 | 34 | #include 35 | 36 | #include 37 | 38 | /*creating a structure of the program*/ 39 | 40 | struct Student 41 | 42 | { 43 | 44 | char Name[50]; 45 | 46 | int RollNo; 47 | 48 | int MobileNo; 49 | 50 | }student; 51 | 52 | /*creating a main() function of the program*/ 53 | 54 | int main() 55 | 56 | { 57 | 58 | strcpy(student.Name, "Maayon"); 59 | 60 | student.RollNo = 1001001 ; 61 | 62 | student.MobileNo = 1010101010 ; 63 | 64 | printf("\nThe student Name is : %s\n",student.Name); 65 | 66 | printf("\nThe student RollNo is : %d\n",student.RollNo); 67 | 68 | printf("\nThe student MobileNo is : %d\n",student.MobileNo); 69 | 70 | } -------------------------------------------------------------------------------- /Structure.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Structure.exe -------------------------------------------------------------------------------- /StructureToFunction.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/StructureToFunction.exe -------------------------------------------------------------------------------- /Switch.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing Decision Making Statements*/ 2 | 3 | /*In C if, if else, nested if , switch , nested Switch are know as Decision Making Statements , which is used to have decision based up on the condition , the statement is executed.*/ 4 | 5 | /*In this Example lets see how SWITCH Statement works in a program.*/ 6 | 7 | /*Switch contains a expression , if the expression meets any equality with the case, then the code/statement/block inside that cse will be executed and remaining cases will be ignored by the compiler.*/ 8 | 9 | /*Note : switch can have any number of case in it.*/ 10 | 11 | /*Syntax of Switch statement 12 | 13 | switch(expression){ 14 | 15 | case constant-expression : 16 | 17 | statement(s); 18 | 19 | break; 20 | 21 | case constant-expression : 22 | 23 | statement(s); 24 | 25 | break; 26 | 27 | default : 28 | 29 | statement(s); 30 | 31 | } 32 | 33 | */ 34 | 35 | /*It is optional to have 'break statement' at end of each case, but it is good pratice to have 'break statement' at end of each case, since it breaks the remaining case and only execute needed case*/ 36 | 37 | /*When no cases statisfy the condition ,then default case will be executed*/ 38 | 39 | /*including preprocessor in the program*/ 40 | 41 | #include 42 | 43 | /*creating a main() function of the program*/ 44 | 45 | int main() 46 | 47 | { 48 | 49 | /* local variable definition */ 50 | 51 | int choise = 2 ; 52 | 53 | /*when the switch case meets the condition then that case will be executed*/ 54 | 55 | /*In this when case is equal to choise then than case will be executed*/ 56 | 57 | /*In this I have designed to execute normal cases*/ 58 | 59 | printf("\nlets see now normal cases in switch.\n"); 60 | 61 | switch(choise) 62 | { 63 | 64 | case 1 : 65 | 66 | printf("\nCase 1 is Executed ,Since Choise is 1\n"); 67 | 68 | break ; 69 | 70 | 71 | case 2 : 72 | 73 | printf("\nCase 2 is Executed ,Since Choise is 2\n"); 74 | 75 | break ; 76 | 77 | case 3 : 78 | 79 | printf("\nCase 3 is Executed ,Since Choise is 3\n"); 80 | 81 | break ; 82 | 83 | case 4 : 84 | 85 | printf("\nCase 4 is Executed ,Since Choise is 4\n"); 86 | 87 | break ; 88 | 89 | default : 90 | 91 | printf("\nSince no Case is met with Choise ,Therefore default case is Executed\n"); 92 | 93 | break ; 94 | 95 | } 96 | 97 | /* Redefining local variable */ 98 | 99 | choise = 5 ; 100 | 101 | /*when the switch case meets the condition then that case will be executed*/ 102 | 103 | /*In this when case is equal to choise then than case will be executed*/ 104 | 105 | /*In this I have designed to execute defalut case*/ 106 | 107 | printf("\nlets see now DEFAULT Case in switch.\n"); 108 | 109 | switch(choise) 110 | 111 | { 112 | 113 | case 1 : 114 | 115 | printf("\nCase 1 is Executed ,Since Choise is 1\n"); 116 | 117 | break ; 118 | 119 | 120 | case 2 : 121 | 122 | printf("\nCase 2 is Executed ,Since Choise is 2\n"); 123 | 124 | break ; 125 | 126 | case 3 : 127 | 128 | printf("\nCase 3 is Executed ,Since Choise is 3\n"); 129 | 130 | break ; 131 | 132 | case 4 : 133 | 134 | printf("\nCase 4 is Executed ,Since Choise is 4\n"); 135 | 136 | break ; 137 | 138 | default : 139 | 140 | printf("\nSince no Case is met with Choise ,Therefore default case is Executed\n"); 141 | 142 | break ; 143 | 144 | } 145 | 146 | } -------------------------------------------------------------------------------- /Switch.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Switch.exe -------------------------------------------------------------------------------- /TypeDef.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about TypeDef in C Program*/ 2 | 3 | /*In C Program typedef is a keyword which is used to give a type to a new name .That is we can able to assign a data type functionallity to a newly decleared variable/name.*/ 4 | 5 | /*In this program lets see a simple typedef used in C Programming*/ 6 | 7 | /*Synatx to define a typedef in c programming 8 | 9 | typedef DataType NewName; 10 | 11 | */ 12 | 13 | 14 | /*including preprocessor in the program*/ 15 | 16 | #include 17 | 18 | #include 19 | 20 | /*creating a main() function of the program*/ 21 | 22 | int main() 23 | 24 | { 25 | 26 | typedef int Number ; 27 | 28 | typedef double RealNumber ; 29 | 30 | typedef char Character ; 31 | 32 | Number a ; 33 | 34 | RealNumber b ; 35 | 36 | Character c; 37 | 38 | printf("\nSize of Number is ::: %d\n",sizeof(Number)); 39 | 40 | printf("\nSize of RealNumber is ::: %d\n",sizeof(RealNumber)); 41 | 42 | printf("\nSize of Character is ::: %d\n",sizeof(Character)); 43 | 44 | printf("\nSize of a Variable which is defined as Number \"a\" is ::: %d\n",sizeof(a)); 45 | 46 | printf("\nSize of a Variable which is defined as RealNumber \"b\" is ::: %d\n",sizeof(b)); 47 | 48 | printf("\nSize of a Variable which is defined as Character \"c\" is ::: %d\n",sizeof(c)); 49 | 50 | } -------------------------------------------------------------------------------- /Typecast.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about TYPECAST in C Program*/ 2 | 3 | /*In this program let see how to how to typecast a variable in c program.*/ 4 | 5 | /*Typecast ia method used in c program for changing a datatype of one variable to another variable in c programming*/ 6 | 7 | /*syntax for typecast is 8 | 9 | (type_name ) expression 10 | 11 | */ 12 | 13 | /*including preprocessor in the program*/ 14 | 15 | #include 16 | 17 | /*creating a main() function of the program*/ 18 | 19 | void main() 20 | 21 | { 22 | 23 | int a= 200; 24 | 25 | float b; 26 | 27 | double c; 28 | 29 | b = ( float) a / 3 ; 30 | 31 | printf("\nThe value of 'b' is : %f\n",b); 32 | 33 | c = ( double ) a / 3 ; 34 | 35 | printf("\nThe value of 'c' is : %lf\n",c); 36 | 37 | } -------------------------------------------------------------------------------- /Typecast.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Typecast.exe -------------------------------------------------------------------------------- /Typedef in Structure.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about TypeDef in C Program*/ 2 | 3 | /*In C Program typedef is a keyword which is used to give a type to a new name .That is we can able to assign a data type functionallity to a newly decleared variable/name.*/ 4 | 5 | /*we can also able to typedef a struct and union as simple as normal typedef*/ 6 | 7 | /*Synatx to define a typedef in c programming 8 | 9 | typedef DataType NewName; 10 | 11 | */ 12 | 13 | /*In this program lets see a Typedef in structure used in C Programming*/ 14 | 15 | /*Synatx to define a typedef in structture in c programming 16 | 17 | typedef struct [structure tag] 18 | 19 | { 20 | 21 | member definition; 22 | 23 | member definition; 24 | 25 | ... 26 | 27 | member definition; 28 | 29 | } [one or more structure variables]; 30 | 31 | */ 32 | 33 | 34 | /*including preprocessor in the program*/ 35 | 36 | #include 37 | 38 | #include 39 | 40 | /*creating a typedef structure of the program*/ 41 | 42 | typedef struct Student 43 | 44 | { 45 | 46 | char Name[50]; 47 | 48 | int RollNo; 49 | 50 | int MobileNo; 51 | 52 | }student; 53 | 54 | /*creating a main() function of the program*/ 55 | 56 | int main() 57 | 58 | { 59 | 60 | student students; 61 | 62 | strcpy(students.Name, "Maayon"); 63 | 64 | students.RollNo = 1001001 ; 65 | 66 | students.MobileNo = 1010101010 ; 67 | 68 | printf("\nThe student Name is : %s\n",students.Name); 69 | 70 | printf("\nThe student RollNo is : %d\n",students.RollNo); 71 | 72 | printf("\nThe student MobileNo is : %d\n",students.MobileNo); 73 | 74 | } -------------------------------------------------------------------------------- /Typedef.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Typedef.exe -------------------------------------------------------------------------------- /TypedefInStructure.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/TypedefInStructure.exe -------------------------------------------------------------------------------- /Union.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about UNIONS in C Program*/ 2 | 3 | /*Unions in C Programming is also know as a user defined Data type which is similar to Structure.*/ 4 | 5 | /*In Structure we can able to store many data of various data type*/ 6 | 7 | /*In Union we can able to store many data of various data type in c programming, in Same memoery location. That is even though many data type is defined but only one member can contain a value at a particular time*/ 8 | 9 | /*Thus Union data type is used to store the memory size which is higher in that Union declearation*/ 10 | 11 | /*Union can be accessed using member access operator ( . ) which is also called as DOT operator*/ 12 | 13 | /*In this program lets see a simple union in C Programming*/ 14 | 15 | /*Synatx to define a Union in c programming 16 | 17 | union [union tag] 18 | 19 | { 20 | 21 | member definition; 22 | 23 | member definition; 24 | 25 | ... 26 | 27 | member definition; 28 | 29 | } [one or more union variables]; 30 | 31 | */ 32 | 33 | /*including preprocessor in the program*/ 34 | 35 | #include 36 | 37 | #include 38 | 39 | /*creating a structure of the program*/ 40 | 41 | union Data 42 | 43 | { 44 | 45 | int a ; /*size of int is 4*/ 46 | 47 | float b ; /*size of float is 4*/ 48 | 49 | char c ; /*size of char is 1*/ 50 | 51 | double d ; /*size of double is 8*/ 52 | 53 | }data ; 54 | 55 | /*creating a main() function of the program*/ 56 | 57 | int main() 58 | 59 | { 60 | 61 | printf("\nMemory size occupied by the INT Data Type in this Program is ::: %d\n",sizeof(data.a)); 62 | 63 | printf("\nMemory size occupied by the FLOAT Data Type in this Program is ::: %d\n",sizeof(data.b)); 64 | 65 | printf("\nMemory size occupied by the CHAR Data Type in this Program is ::: %d\n",sizeof(data.c)); 66 | 67 | printf("\nMemory size occupied by the DOUBLE Data Type in this Program is ::: %d\n",sizeof(data.d)); 68 | 69 | printf("\nMemory size occupied by the UNION Data Type in this Program is ::: %d\n",sizeof(data)); 70 | 71 | } 72 | 73 | -------------------------------------------------------------------------------- /Union.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Union.exe -------------------------------------------------------------------------------- /Variable.c: -------------------------------------------------------------------------------- 1 | /*inculding preprocessor*/ 2 | 3 | #include 4 | 5 | /*main function of a programing*/ 6 | 7 | int main() 8 | { 9 | 10 | /*Note: the syntax for varibale definition is "data_type variable_name = value; " or "data_type variable_name; " or "data_type variable_name1,variable_name2,,.....variable_namen;"*/ 11 | 12 | /* A Variable Name can be of any user defined here in this program i have given a,b,c as a variable name*/ 13 | 14 | int a= 5; 15 | 16 | char b='a'; 17 | 18 | float c=20.450; 19 | 20 | /*Accessing the variable value by using the variable name*/ 21 | 22 | printf("\nThe value of int a is : %d \n",a); 23 | 24 | printf("\nThe value of char b is : %c \n",b); 25 | 26 | printf("\nThe value of float c is : %f \n",c); 27 | 28 | } -------------------------------------------------------------------------------- /Variable.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/Variable.exe -------------------------------------------------------------------------------- /While Loop.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about LOOPS in C Program*/ 2 | 3 | /*In C while, do while, for are different loop Statements , which is used to execute certain number of codes for certain number of times. That is the code inside the loop will be execute certain number of times till the condition fails and loop comes out of the scope.*/ 4 | 5 | /*In this Example lets see how WHILE LOOP works in a program.*/ 6 | 7 | /*While loop is kind of LOOP , which is used to execute the code for certain number of times, till the condition fails. While loop is also know as 'ENTERY CHECK LOOP',that is loop will be execute only is the condition is True, if the condition is fails then the loop stop executing.*/ 8 | 9 | /*Syntax of while loop 10 | 11 | while(condition) 12 | 13 | { 14 | 15 | Statement(S) / block of code; 16 | 17 | Increment; 18 | 19 | } 20 | 21 | */ 22 | 23 | /*including preprocessor in the program*/ 24 | 25 | #include 26 | 27 | /*creating a main() function of the program*/ 28 | 29 | int main() 30 | 31 | { 32 | 33 | /* local variable definition */ 34 | 35 | int a = 1 ; 36 | 37 | /*while loop*/ 38 | 39 | while ( a <= 10) /*While loop condition,Where condition will be checked.*/ 40 | 41 | { 42 | 43 | printf("\nValue of a = %d\n",a); 44 | 45 | printf("\nThe WHILE LOOP is executed for %d\n",a); 46 | 47 | a++; /*Increment the value of variable a */ 48 | 49 | } /*End of while loop */ 50 | 51 | printf("\nThe WHILE LOOP is executed for %d number of times\n",a-=1); 52 | 53 | } -------------------------------------------------------------------------------- /WhileLoop.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/WhileLoop.exe -------------------------------------------------------------------------------- /Write File.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about FILES in C Program*/ 2 | 3 | /*In this program let see how to open or write in a txt file in c program.*/ 4 | 5 | /*fopen() is a function used to open a file or create a file in c program*/ 6 | 7 | /*fclose() is a function used to close a file in c program*/ 8 | 9 | /*synatx for fopen() 10 | 11 | FILE *fopen( const char * filename, const char * mode ); 12 | 13 | */ 14 | 15 | /*filename is the name of the file*/ 16 | 17 | /*mode is in which mode the file is used*/ 18 | 19 | /*There are 6 types of mode to read files. They are*/ 20 | 21 | /* 1 - 'r' = open in read only mode.*/ 22 | 23 | /* 2 - 'w' = open in write only mode.*/ 24 | 25 | /* 3 - 'a' = open in append only mode.*/ 26 | 27 | /* 4 - 'r+' = open in both read and write mode.*/ 28 | 29 | /* 5 - 'w+' = open in read and write mode.*/ 30 | 31 | /* 6 - 'a+' = open in read and write mode.Reading is done from beginning and write can only be appended*/ 32 | 33 | /*In this program let see about how to create / open a file and write into that file*/ 34 | 35 | /*synatx for writing into file is 36 | 37 | fprintf(fp ,"content"); 38 | 39 | or 40 | 41 | fputs("content",fp); 42 | 43 | */ 44 | 45 | /*including preprocessor in the program*/ 46 | 47 | #include 48 | 49 | /*creating a main() function of the program*/ 50 | 51 | void main() 52 | 53 | { 54 | 55 | /*opening file in write and read mode*/ 56 | 57 | FILE *fileptr = fopen("C:/Users/MAAYON/Desktop/c/Maayon.txt", "w+"); 58 | 59 | /*writing using fprintf()*/ 60 | 61 | fprintf(fileptr, "This is Maayon...\n"); 62 | 63 | /*writing using fputs()*/ 64 | 65 | fputs("\nThis is my first program in Files in C Program...\n", fileptr); 66 | 67 | fclose(fileptr); 68 | 69 | } -------------------------------------------------------------------------------- /WriteFile.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/WriteFile.exe -------------------------------------------------------------------------------- /define.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/define.exe -------------------------------------------------------------------------------- /getchar & putchar.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about INPUT AND OUTPUT in C Program*/ 2 | 3 | /*in this program lets see aboyt getchar() and putchar() function in c program*/ 4 | 5 | /*In simple getchar() is used to get only one character as a input from user*/ 6 | 7 | /*In simple putchar() is used to display only first character from a variable*/ 8 | 9 | /*including preprocessor in the program*/ 10 | 11 | #include 12 | 13 | /*creating a main() function of the program*/ 14 | 15 | void main() 16 | 17 | { 18 | 19 | char c; 20 | 21 | printf("Enter your name : "); 22 | 23 | c = getchar(); 24 | 25 | printf("\n\nYou have entered : "); 26 | 27 | putchar(c); 28 | 29 | } -------------------------------------------------------------------------------- /getcharputchar.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/getcharputchar.exe -------------------------------------------------------------------------------- /gets puts.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about INPUT AND OUTPUT in C Program*/ 2 | 3 | /*in this program lets see about gets() and puts() function in c program*/ 4 | 5 | /*In simple gets() is used to get all character as a input from user*/ 6 | 7 | /*In simple puts() is used to display all character from a variable*/ 8 | 9 | /*including preprocessor in the program*/ 10 | 11 | #include 12 | 13 | #include 14 | 15 | /*creating a main() function of the program*/ 16 | 17 | void main() 18 | 19 | { 20 | 21 | char c[50]; 22 | 23 | printf("\nEnter your name : "); 24 | 25 | gets( c ); 26 | 27 | printf("\n\nYou have entered : "); 28 | 29 | puts(c); 30 | 31 | } -------------------------------------------------------------------------------- /getsputs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/getsputs.exe -------------------------------------------------------------------------------- /goto.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about LOOPS CONTROL STATEMENTS in C Program*/ 2 | 3 | /*In C break , continue , goto are called as LOOP CONTROL STATEMENT, which is been used for contoling the flow of loop in a c program.*/ 4 | 5 | /*In this Example lets see how GOTO works in a program.*/ 6 | 7 | /*goto is a type of loop control statement which is used for unconditional jump from the goto statement to the lable/destination statement in the same function.*/ 8 | 9 | /*Note: using goto in c program isd highly not encouraged , thus just learn how it works in a program*/ 10 | 11 | /*Syntax of goto 12 | 13 | goto label; 14 | 15 | .. 16 | 17 | . 18 | 19 | label : statement; 20 | 21 | */ 22 | 23 | /*including preprocessor in the program*/ 24 | 25 | #include 26 | 27 | /*creating a main() function of the program*/ 28 | 29 | int main() 30 | 31 | { 32 | 33 | /*Note : This program will be resulting in infinite loop*/ 34 | 35 | GOTO : for ( int i = 1 ; i <= 10 ; i++) 36 | 37 | { 38 | 39 | if ( i == 7) 40 | 41 | { 42 | 43 | printf("\ngoto has been applied . Thus the loop has been jumped to the lable GOTO statement.\n"); 44 | 45 | goto GOTO; 46 | 47 | } 48 | 49 | printf("\nValue of i = %d\n",i); 50 | 51 | } 52 | 53 | printf("\ngoto Statement has executed SUCCESSFULLY.....\n"); 54 | 55 | } -------------------------------------------------------------------------------- /goto.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/goto.exe -------------------------------------------------------------------------------- /if else if.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing Decision Making Statements*/ 2 | 3 | /*In C if, if else, nested if , switch , nested Switch are know as Decision Making Statements , which is used to have decision based up on the condition , the statement is executed*/ 4 | 5 | /*In this Example lets see how If Else If Statement works in a program*/ 6 | 7 | /*Syntax of If else if statement 8 | 9 | if(boolean_expression 1) 10 | 11 | { 12 | 13 | statement 1; 14 | 15 | statement 2; 16 | 17 | . 18 | . 19 | . 20 | 21 | statement n; 22 | 23 | } 24 | 25 | else if(boolean_expression 2) 26 | 27 | { 28 | 29 | statement 1; 30 | 31 | statement 2; 32 | 33 | . 34 | . 35 | . 36 | 37 | statement n; 38 | 39 | } 40 | 41 | else if(boolean_expression 3) 42 | 43 | { 44 | 45 | statement 1; 46 | 47 | statement 2; 48 | 49 | . 50 | . 51 | . 52 | 53 | statement n; 54 | 55 | } 56 | 57 | 58 | . 59 | . 60 | . 61 | . 62 | 63 | else if(boolean_expression n) 64 | 65 | { 66 | 67 | statement 1; 68 | 69 | statement 2; 70 | 71 | . 72 | . 73 | . 74 | 75 | statement n; 76 | 77 | } 78 | 79 | 80 | else 81 | 82 | { 83 | 84 | statement 1; 85 | 86 | statement 2; 87 | 88 | . 89 | . 90 | . 91 | 92 | statement n; 93 | 94 | } 95 | 96 | */ 97 | 98 | /*including preprocessor in the program*/ 99 | 100 | #include 101 | 102 | /*creating a main() function of the program*/ 103 | 104 | int main() 105 | 106 | { 107 | 108 | /* local variable definition */ 109 | 110 | int a = 30; 111 | 112 | /* check the boolean condition using if statement */ 113 | 114 | /*If the Boolean expression evaluates to true, then the if block will be executed, 115 | else then else if block will be executed,Otherwise else will be Executed*/ 116 | 117 | /*Note : you can able to have any number of else if condition*/ 118 | 119 | /*In this 'a' is decleared as 30 , therefore when the condition is true then that particular if else block will be executed and remainings are ignored by the complier*/ 120 | 121 | if( a == 0 ) 122 | 123 | { 124 | 125 | printf("\na is ZERO\n" ); 126 | 127 | printf("\nIF STATEMENT IS EXECUTED\n"); 128 | 129 | } 130 | 131 | else if( a == 10 ) 132 | 133 | { 134 | 135 | printf("\na is TEN\n" ); 136 | 137 | printf("\nFIRST ELSE IF STATEMENT IS EXECUTED\n"); 138 | 139 | } 140 | 141 | else if( a == 20 ) 142 | 143 | { 144 | 145 | printf("\na is TWENTY\n" ); 146 | 147 | printf("\nSECOND ELSE IF STATEMENT IS EXECUTED\n"); 148 | 149 | } 150 | 151 | else if( a == 30 ) 152 | 153 | { 154 | 155 | printf("\na is THRITY\n" ); 156 | 157 | printf("\nTHRID ELSE IF STATEMENT IS EXECUTED\n"); 158 | 159 | } 160 | 161 | else if( a == 40 ) 162 | 163 | { 164 | 165 | printf("\na is FOURTY\n" ); 166 | 167 | printf("\nFOURTH ELSE IF STATEMENT IS EXECUTED\n"); 168 | 169 | } 170 | 171 | else 172 | 173 | { 174 | 175 | printf("\na is MORE THAN FOURTY20\n" ); 176 | 177 | printf("\nELSE STATEMENT IS EXECUTED\n"); 178 | 179 | } 180 | 181 | printf("\nvalue of a is : %d\n", a); 182 | 183 | } -------------------------------------------------------------------------------- /if else.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing Decision Making Statements*/ 2 | 3 | /*In C if, if else, nested if , switch , nested Switch are know as Decision Making Statements , which is used to have decision based up on the condition , the statement is executed*/ 4 | 5 | /*In this Example lets see how If Else Statement works in a program*/ 6 | 7 | /*Syntax of If else statement 8 | 9 | if(boolean_expression) 10 | 11 | { 12 | 13 | statement 1; 14 | 15 | statement 2; 16 | 17 | . 18 | . 19 | . 20 | 21 | statement n; 22 | 23 | } 24 | 25 | else 26 | 27 | { 28 | 29 | statement 1; 30 | 31 | statement 2; 32 | 33 | . 34 | . 35 | . 36 | 37 | statement n; 38 | 39 | } 40 | 41 | */ 42 | 43 | /*including preprocessor in the program*/ 44 | 45 | #include 46 | 47 | /*creating a main() function of the program*/ 48 | 49 | int main() 50 | 51 | { 52 | 53 | /* local variable definition */ 54 | 55 | int a = 10; 56 | 57 | /* check the boolean condition using if statement */ 58 | 59 | /*If the Boolean expression evaluates to true, then the if block will be executed, 60 | otherwise, the else block will be executed.*/ 61 | 62 | /*In this the condition which is given is False since a is less than 20 but the condition is a is greater than 20 .Therefore the condition fails and else , Else statement will be Executed */ 63 | 64 | if( a > 20 ) 65 | 66 | { 67 | 68 | printf("\na is GREATER THAN 20\n" ); 69 | 70 | printf("\nIF STATEMENT IS EXECUTED\n"); 71 | 72 | } 73 | 74 | else 75 | 76 | { 77 | 78 | printf("\na is LESSER THAN 20\n" ); 79 | 80 | printf("\nELSE STATEMENT IS EXECUTED\n"); 81 | 82 | } 83 | 84 | printf("\nvalue of a is : %d\n", a); 85 | 86 | 87 | /*Redifinied local variable a from 10 to 30 */ 88 | 89 | a = 30; 90 | 91 | /* check the boolean condition using if statement */ 92 | 93 | /*If the Boolean expression evaluates to true, then the if block will be executed, 94 | otherwise, the else block will be executed.*/ 95 | 96 | /*In this the condition which is given is True since a is Greater than 20, the condition is a is greater than 20 .Therefore the condition is True and else , If statement will be Executed */ 97 | 98 | if( a > 20 ) 99 | 100 | { 101 | 102 | printf("\na is GREATER THAN 20\n" ); 103 | 104 | printf("\nIF STATEMENT IS EXECUTED\n"); 105 | 106 | } 107 | 108 | else 109 | 110 | { 111 | 112 | printf("\na is LESSER THAN 20\n" ); 113 | 114 | printf("\nELSE STATEMENT IS EXECUTED\n"); 115 | 116 | } 117 | 118 | printf("\nvalue of a is : %d\n", a); 119 | 120 | 121 | } -------------------------------------------------------------------------------- /ifelse.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ifelse.exe -------------------------------------------------------------------------------- /ifelseif.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/ifelseif.exe -------------------------------------------------------------------------------- /input.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/input.exe -------------------------------------------------------------------------------- /pointer.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/pointer.exe -------------------------------------------------------------------------------- /scanf printf.c: -------------------------------------------------------------------------------- 1 | /*In this program we will be seeing about INPUT AND OUTPUT in C Program*/ 2 | 3 | /*in this program lets see about scanf() and printf() function in c program*/ 4 | 5 | /*In simple scanf() is used to get all character as a input from user*/ 6 | 7 | /*In simple printf() is used to display all character from a variable*/ 8 | 9 | /*most of the programer will be useing scanf() and printf() commonly*/ 10 | 11 | /*including preprocessor in the program*/ 12 | 13 | #include 14 | 15 | #include 16 | 17 | /*creating a main() function of the program*/ 18 | 19 | void main() 20 | 21 | { 22 | 23 | int age; 24 | 25 | float income; 26 | 27 | char name[50]; 28 | 29 | printf("\nEnter your name : "); 30 | 31 | scanf( "%s",&name ); 32 | 33 | printf("\nEnter your age : "); 34 | 35 | scanf( "%d",&age ); 36 | 37 | printf("\nEnter your income : "); 38 | 39 | scanf( "%f",&income ); 40 | 41 | printf("\n\nYour name is : %s\n",name); 42 | 43 | printf("\nYour age is : %d\n",age); 44 | 45 | printf("\nYour income is : %f\n",income); 46 | 47 | } -------------------------------------------------------------------------------- /scanfprintf.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ajay2521/Complete-C-Programming/61ebad03520ebc705c0120a8064e268fa05cada3/scanfprintf.exe --------------------------------------------------------------------------------