Structure of c program

 Structure of c program:-

By the structure , it means that any program can be written in this structure only . writing a c program in any other stucture will hence lead to a compilation error.

The structure of a c program is following:-


Explanation:-

(1) Header file:-

    A header file is a file with extension.h , which contains C functions and macro definitions to be shared between several source files.

(Ex:- <stdio.h> , <conio.h> , <math.h> , <string.h>

(2) Main function :-

    The main function is declared in c program by following syntax:-

int main()                 void main()
   {}             or           {}


(3) Variable declaration :- 

    it is mandatory to declare th variable type in c programs while using variable , without declaration th program will showing error while compilation.

Example:-

int main()
{
    int a;
.


(4) Body :-

     The body of the c programs ,refers to the operations that are performed in the functions.It can be anything like searching ,sorting , printing etc.


int main()
{
    int a;

    printf("%d", a);
.
.


(5) Return statement :-

       The last part of any c program is return statement . The return statements refers to the returning of the value from a function . 

        This return statement and return value depends upon return type of function .(If return type is void , then there will be no return statement . In other case , there will be a return value.

Example:-

int main()
{
    int a;

    printf("%d", a);

    return 0;
}


* Our first C program :-


#include <stdio.h>
int main(void)
{
    printf("Code with AD");
    return 0;
}




Please comment below for any type of fault in the article or any type of help or problem. Thanku to visit our site.🙏🙏

Code with AD

Hii connection! This is Adarsh Kumar_ From Patna , Bihar(India)_ I am pursing graduation from AN college, Patna.

2 Comments

Post a Comment
Previous Post Next Post