By: Ram Viewed: 1380 times Printer Friendly Format
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.
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
The assignment statement is used to assign a constant to a variable.
Variable = Variable;
Eg: (assigned to a constant)
Eg: (assigned to a variable)
Eg: (assigned to a expression)
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
Without exponent %f
With exponent %e
The output is Hello
The output is the value of x
Eg: printf(“sum %d”,s)
The output is sum value of s
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,);
It asks for the value of n
Eg: scanf(“%d %d”,&a,&b);
40 (ie.a=20 and b=40)
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.
2. goto end
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.
Structure of a Program:
(to link with other programs)
Global declaration Section
/* program to find area of a square*/
printf(“enter the side “);
printf(“Area of a square= %d”,a);
Most Viewed Articles (in C )
Latest Articles (in C)
Comment on this tutorial
- Cloud Computing
- Java Beans
- Mac OS X
- Office 365
- Tech Reviews