Structure of a program
Structure of a program
Every C program consists of one or more modules called functions.
One of these functions is called main. The program begins by executing main
function and access other functions, if any. Functions are written after or before
main function separately.
A function has:
(1) heading consists of name with list of arguments ( optional ) enclosed in parenthesis,
(2) argument declaration (if any) and
(3) compound statement enclosed in two braces { } such that each statement ends with a semicolon. Comments, which are not executable statement, of necessary can be placed in between /* and */.
Example
/* program to find the area pf a circle */
#include<stdio.h>
main( )
{
float r, a;
printf(“radius”);
scanf(“%f”, &r);
a=3.145*r*r;
printf(“area of circle=%f”, area);
}
Every C program consists of one or more modules called functions.
One of these functions is called main. The program begins by executing main
function and access other functions, if any. Functions are written after or before
main function separately.
A function has:
(1) heading consists of name with list of arguments ( optional ) enclosed in parenthesis,
(2) argument declaration (if any) and
(3) compound statement enclosed in two braces { } such that each statement ends with a semicolon. Comments, which are not executable statement, of necessary can be placed in between /* and */.
Example
/* program to find the area pf a circle */
#include<stdio.h>
main( )
{
float r, a;
printf(“radius”);
scanf(“%f”, &r);
a=3.145*r*r;
printf(“area of circle=%f”, area);
}
Comments
Post a Comment