C programming Structure and Examples

C Program Structure:- 

सी प्रोग्राम का स्ट्रक्चर निम्न है -

1.) Include section
//pre processor directives like #include.

2.) Define global constants/macro
//pre processor directives #define or extern storage class variables/constant.

3.) Other functions definition (pre processor)

4.) Main function
     a.) Variable Declaration/Initialization.
     b.) Declaration of other functions (post processor)
     b.) Executable Statements.

5.) Other functions definition (post processor)


Example:-

C Program for Simple Interest-

file:- si.c

#include<stdio.h>
#include<conio.h>
int main(){
float p,r,t,si;
clrscr();
printf("Enter Principal,Rate and Time\n");
scanf("%f%f%f",&p,&r,&t);
si=p*r*t/100;
printf("Simple Interest=%f",si);
getch();
return 1;
}

No comments:

Post a Comment