Basics of C Programming

⯈Basic C Programs

Types of initializations

Initialization is assigning values to the variables. These values can be assigned in two ways:

  1. Compile time initialization.
  2. Run time initialization.

Compile time initialization

In compile time initialization, the values of the variables are known before we run the program.

There are some situations where we need to initialize the variable during compile time. 

Say for example, if we know that the maximum limit of an array is 100, we can write

int max = 100;

//Program for compile-time initialization
int main()
int a = 10;
return 0;

Run time initialization

In run time initialization, we will know the values of the variables when we run the program. To read the values at the run time we use input functions (formatted / unformatted)

//Program for run-time initialization
int main()
int a;
printf("Enter value for a:");
scanf("%d", &a);
return 0;
Scroll to Top