How to write a program in ' C ' language

•Stracture of 'C' program

Before understanding the structure of c programe you must know these important points :

° c is a case of sensitive language , it means all the key words must be written in lower case.
°key words can't be used as variable or function name.
°every instruction should be end with [;] sign.
°Preprocessor directives (required) should be there in the beginning.
°Function main() is must for a program.

Now to write a program in c we need to follow these steps:

•Define preprocessor directives( include header file according to prototype function, standard I/O library function to used).
•open function main()
•Assign data types and variables.
•Define the body of the function main()
-------------------------------------------------------------------

Example:-

/*harshit.c:first example for students*/
#include<stdio.h>
void main()
{
int a= 10 ,b=15,c;
printf ( Hello students welcome in my site I am harshit \n");
c=a+b;
printf ( " The sum of %d and %d is % d,a,b,c);
}
-------------------------------------------------------------------
in the above example the first line 
/*harshit.c: first example for students*/
is a comment and non executable. Comments in C begin with (/*) and ends with (*/).

second line

#include<stdio.h>
is a preprocessor directive. The preprocessor processes the C program before the compiler. Here stdio.h is a header file consists of standard I/O function. A heder file related to the function used in program should be included at the beginning.

The line

void main()
indicate the beginning of the program.The compilation of the program starts from main() function.
{, symbol indicates the beginning of main () function.

The line

int  a=10,b=15,C;
is for declaration of variable and data types.

The line

printf ( " The sum of %d and % d is %d,a,b,c);
are the body of the program.
and symbol'}' indicates end of main() function.
                                               
                              ___ By Harshit Kumar

Comments

Popular posts from this blog

How To Hack Wifi | Hack Wifi Password | TECH WORTH MIND

Remove Tools From Termux | How can I reopen the installed tool in termux? | TECH WORTHY MIND