What is C Program? C is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, including operating systems, as well as various application software for computers ranging from supercomputers to embedded systems. 1.Header Files. A header file is a file with extension .h which contains C function declarations and macro definitions to be shared between several source files. There are two types of header files: the files that the programmer writes and the files that comes with your compiler. 2.Variables 3.Integer Types. 4.Operators in C. I.Arithmetic Operators Logical Operators. Bit-wise Operators. Assignment Operators. Misc Operators. II.Relational Operators III.Logical Operators IV. Bit-wise Operators V.Assignment Operators VI.Misc Operators 5.Decision Making 6.Loops. 7.Functions. What are Functions? A function is a group of statements that together perform a task. Every C program has at least onefunction, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions. Defining a Function Calling a Function return(num3); } OUTPUT: 8.Arrays. What are Arrays? An array is a collection of data items, all of the same type, accessed using a common name. A one-dimensional array is like a list; A two dimensionalarray is like a table; The C language places no limits on the number of dimensions in an array, though specific implementations may. 9.Pointers. What are Pointers? A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location.
NULL Pointers It is always a good practice to assign a NULL value to a pointer variable in case you do not have an exact address to be assigned. This is done at the time of variable declaration. A pointer that is assigned NULL is called a null pointer. int *ptr = NULL; printf(“The value of ptr is : %x\n”, ptr ); return 0; } OUTPUT: 10.Strings. What are Strings? 11.Structures. What are Structures? Structure is a user-defined data type in C which allows you to combine different data types to store a particular type of record. … The only difference is that array is used to store collection of similar datatypes while structure can store collection of any type of data. Structure is used to represent a record. Defining a structure struct keyword is used to define a Structure. struct define a new data type which is a collection of different type of data. Syntax: Array of Structure We can also declare an array of structure. Each element of the array representing a structure variable. Eg: Structure as function arguments We can pass a structure as a function argument in similar way as we pass any other variable or array. Eg: 12.Input & Output. When we say Input, it means to feed some data into a program. An input can be given in the form of a file or from the command line. When we say Output, it means to display some data on screen, printer, or in any file. The scanf() and printf() Functions scanf(): In C programming language, scanf() function is used to read character, string, numeric data from keyboard.Consider below example program where user enters a character. This value is assigned to the variable “ch” and then displayed.Then, user enters a string and this value is assigned to the variable “str” and then displayed. printf():In C programming language, printf() function is used to print the “character, string, float, integer, octal and hexadecimal values” onto the output screen.We use printf() function with %d format specifier to display the value of an integer variable.Similarly %c is used to display character, %f for float variable, %s for string variable, %lf for double and %x for hexadecimal variable. To generate a newline,we use “\n” in C printf() statement. getchar() and putchar() Functions The int getchar(void) function reads the next available character from the screen and returns it as an integer. This function reads only single character at a time. You can use this method in the loop in case you want to read more than one character from the screen. The int putchar(int c) function puts the passed character on the screen and returns the same character. This function puts only single character at a time. You can use this method in the loop in case you want to display more than one character on the screen. 13.Recursion. Recursion is the process of repeating items in a self-similar way. In programming languages, if a program allows you to call a function inside the same function, then it is called a recursive call of the function.