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:

  1. Macros
  2. File inclusion
  3. Conditional Compilation
  4. 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;
}


Output

Hi! This is a basic C program.

Similar Reads

Tokens

...

Semicolons

A token in C programming is either a keyword, an identifier, a constant, a string literal, or a symbol. Let’s get a good understanding of tokens through a print statement in C language....

Preprocessor Directives

In C programming Semicolon is used to show the termination of Instruction. It is also called a statement terminator since every single statement should be ended with a semicolon. Semicolons are used to end statements in C....

Identifiers in C

...

C Keywords

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....

Comments in C

In C programming, the identifier is used to identify a variable, function, or any other user-defined data type. C programming language does not allow special characters such as $, @, or % within the identifier....

Whitespaces in C

In the C programming language, keywords are reserved words that have special meanings. These reserved words can’t be used as variables or constants or any other identifier name. C contains a total of 32 keywords that are reserved and have special meanings....

Functions

In C programming Comments are used to make any program more readable and understandable. Comments are generally used by programmers to add explanations or descriptive text in the code without any interference from the compiler or the programming structure....