Statements in C

By: Ram Emailed: 1728 times Printed: 2329 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

All the statements in C ends with a “;”. The various statements in C are

1)      Declaration Statement

2)      Assignment Statement

3)      Output  Statement

4)      Input Statement

5)      Control Statement

6)      Loop Statement etc.


Declaration Statement:-

It is used to specify the data type of variables used in the program



 Datatype Variable or variables separated by , ;


Eg- int b;

Here the variable b is int and it allots 2 bytes


Eg- int c,e;

Here the variables c and e are int and it allots 4 bytes


Eg- float n1,n2;

Here n1, and n2 are declared as float and hence allotted 4 bytes each



Assignment Statement:-

The assignment statement is used to assign a constant to a variable.





Variable =    Variable;




Eg: (assigned to a constant)

            a= 5;

             b =10;

Eg: (assigned to a variable)


             a= 2*e;

Eg: (assigned to a expression)

            y= c*d

            s= 4*20


Output Statement:

The output statement displays the values and after printing the values it points on the same line.



 printf(“string format”, variable or variables separated by ,);


Here the format means the data specification of the variable. Say, for example


  integer                  format


 Decimal                  %d

 Octal                       %o

 Hexadecimal           %x


float                           format


Without exponent       %f

With exponent            %e


Char                            %c




Eg:   printf(“Hello World”);

The output is Hello World 


Eg:  printf(“%d”,x)

The output is the value of x 


Eg: printf(“sum %d”,s)

The output is sum value of s


Input Statement:

The input statement is used to read(accept) constant at the variable at the time of program execution.



      scanf(“format”, & variable or &variables separated by comma,);


Eg: scanf(“%d”,&n);

      It asks for the value of n

Eg: scanf(“%d %d”,&a,&b);

         run 20

                40 (ie.a=20 and b=40)


Control Statement:

The control statement denotes the sequence of execution of the program. There are two types of control statements namely: conditional control statement and unconditional control statement.


(1)Conditional control statement:

Here, the control is transferred to any part of the program without checking for any condition.


1. --------------

2. goto end

3. -------------

4. end:

5. -------------



Eg: goto labelname

The control is transferred to the line where the label starts as shown above.


(2) Unconditional control statement:

Here, the condition is first checked and if it is true then the executes that particular part and if false, then another part is executed.


Eg:  if




Loop Statement:

Loop statements are mainly used in programs to do repeated calculations.

Eg: while

       do ………….while




               while (conditions)





Structure of a Program:


Documentation Section

(remarks- comments)


Link section

(to link with other programs)


Global declaration Section

(common declaration)




Declaration statement;

Statement part;


Sub programs




Sample Program:

/* program to find area of a square*/



 int s,a;

printf(“enter the side “);



printf(“Area of a square= %d”,a);



C Home | All C Tutorials | Latest C Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Bookmark and Share


Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by Ram
smskannel SMS gateway run in background
while, do while and for loops in C
Statements in C
Writing The First C program

More Tutorials in C
Sum of the elements of an array in C
Printing a simple histogram in C
Sorting an integer array in C
Find square and square root for a given number in C
Simple arithmetic calculations in C
Command-line arguments in C
Calculator in C
Passing double value to a function in C
Passing pointer to a function in C
Infix to Prefix And Postfix in C
while, do while and for loops in C
Unicode and UTF-8 in C
Formatting with printf in C
if, if...else and switch statements in C with samples
Statements in C

More Latest News
Most Viewed Articles (in C )
Using memset(), memcpy(), and memmove() in C
goto and labels in C
Find square and square root for a given number in C
Open, Creat, Close, Unlink system calls sample program in C
Using calloc() Function in C
perror() Function - example program in C
Sorting an integer array in C
Character Arrays in C
scanf and sscanf sample program in C
lseek() sample program in C
Arrays sample program in C
register Variables in C
Arrays of Structures example program in C
union example program in C
fgets(), fputs() - Line Input and Output - sample program in C
Most Emailed Articles (in C)
Listing Files and Directories sample program in C
Arithmetic Operators in C
Relational and Logical Operators in C
Increment and Decrement Operators in C
register Variables in C
File Inclusion in C
Pointers and Function Arguments in C
Pointers and Arrays in C
Character Pointers and Functions in C
Pointer Arrays and Pointers to Pointers in C
Multi-dimensional Arrays in C (Explained using date conversion program)
Initialization of Pointer Arrays in C
The Birth and history of C Programming Language
Basics of C
Getting Started with C