Preprocessor Directives
In C language, a program should begin with preprocessor directives since they contain multiple files that contain specific functions. Preprocessors in C are used to process our source code before compilation.
There are 4 main types of Preprocessor directives in C:
- Macros
- File inclusion
- Conditional Compilation
- Other directives
While executing a program in C multiple steps are involved as mentioned below:
C Basic Syntax
C is a procedural programming language. It was developed by Dennis Ritchie at the Bell Laboratories in the year 1972. Despite being old C is a very popular language among programmers. It is a very fast language compared to other languages like Python, Java, etc.
Below is the basic syntax structure of the C program:
The basic syntax of the C program consists of the header, main() function, variable declaration, body, and return type of the program.
- The header is the first line in the C program with extension .h which contains macro definitions and C functions.
- Programs must contain the main() function because execution in C programming starts from the main().
- Variable declaration in C is done inside the main function and can be used in the body anywhere but before the main, we can also declare variables which are known as Global variables.
- In the body of the function, we perform operations required inside the function like printing, sum, average, sorting, searching, etc.
- The last part of the C program is the return statement which refers to returning values of the program. If the return type is void then there will be no return statement.
C
// Basic Syntax of C Program #include <stdio.h> // main function int main() { // body printf ( "Hi! This is a basic C program." ); // return statement return 0; } |
Hi! This is a basic C program.