Instructions in C languages

instructions in c

Now that we have written a few programs, let’s look at the instructions we used in these programs. There are basically three types of instructions in C:

  • Type Declaration
  • Instruction Arithmetic
  • Instruction Control Instruction

The purpose of each of these instructions is set out below:

Type declaration instruction To declare the type of variables used in a C program.
Arithmetic instruction To declare the type of variables used in a C program.
Control instruction To control the sequence of execution of various statements in a C program.

Whereas, elementary Instructions in C would usually contain only the type statement and the arithmetic instructions; we will only discuss these two instructions at this stage. The other types of instructions will be discussed in more detail in the following chapters.

Type Declaration Instructions in C

This statement is used to declare the type of variables used in the program. Any variable used in the program must be declared before using it in any declaration. The type declaration declaration is written at the beginning of the main function ().

Ex.: int bas ;
 float rs, grosssal ;
 char name, code ; 

There are several subtle variations of the type statement statement. These are discussed below:

  • While declaring the type of variable, we can initialize it, as shown below.
nt i = 10, j = 25 ;
float a = 1.5, b = 1.99 + 2.4 * 1.44 ; 

The order in which we define variables is sometimes important, sometimes not. E.g,

int i = 10, j = 25 ;

is same as

int j = 25, j = 10 ;


float a = 1.5, b = a + 3.1 ;

is alright, but

float b = a + 3.1, a = 1.5 ; 

is not. This is because here we try to use one just before defining it.

The following statements would work

int a, b, c, d ;
a = b = c = 10 ; 

However, the following statement will not work

int a = b = c = d = 10 ; 

Again we try to use b (to assign a) before defining it.

Youo can get more C related topics here

Leave a Comment