purpose of various parts of c progrm
1.Header file section:-Header file is defined at start of program.It is defined at head of program so it is called as header file.the name of header file is followed by "extention.h".The ".h" means header.The header file begins with # (hash or sharp) symbol.
e.g stdio.h is file used for standerd input/output function.Some of functions defined in this file are "scanf(), printf(), fscanf(), fopen(), fclose(), fof()".
e.g conio.h is file used for console input/output functions.Some of the functions defined in this file are "getch(), clerscr()".
e.g stdlib.h is used as standard library function.It contain "malloc(), calloc(), toupper(), tolower() functions"
e.g math.h is a file containing mathematical function.It contain "sqrt(), pow(), floor(), ceil(), sin(), cos()" functions.
2. Name of a program:- It is used to indicate the purpose of program.It indicate what is problem to be solved by program.It is given using comment operator at start of program.It is optional.
3.Main function:- The main function contain keyword main().It is indication to the compiler that program execution will be start from main().So main() is starting point of any program.There is only one main() in a c program.In main() function the logic of program is written.All statements and logic is written between pair of curly brackets{}.
4.Declaration part:- This part is used to declare variables of different data types.Initialization of variable is also done in this section.By initialization , we assign starting value to variables.
5.Executable part:- This part follows declaration part.In this part set of statements performing various, functions are defined.There can be single statement or set of statements.Single statement can be written without curly brackets({}).Compound statements are are written using pair of curly brackets({}).
6.User defined function:- The function defined by user is called as user defined functions.These function are generally defined after main() function.There can be any number of user defined functions but there is only one main function.The body of these functions can be defined before main() function also.If body of functions is defined after main then prototype of function is defined above body of main() function.
7.Comments:-The comments are not necessary.But for good documentation these are added.Comment can be inserted anywhere in program.These are given by writing text between \* and * \.
Delimiters : Special type of symbols used for special purpose is called as delimiter.
e.g.
colon :
semi colon ;
parenthesis ( )
hash #
comma ,
square bracket []
SAMPLE OF A 'C' PROGRAM :-
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
a=5;
b=6;
c=a+b;
printf("The value of c= %d",c);
getch();
}
OUTPUT :_
c=11
Download area.......
Download TCC
e.g stdio.h is file used for standerd input/output function.Some of functions defined in this file are "scanf(), printf(), fscanf(), fopen(), fclose(), fof()".
e.g conio.h is file used for console input/output functions.Some of the functions defined in this file are "getch(), clerscr()".
e.g stdlib.h is used as standard library function.It contain "malloc(), calloc(), toupper(), tolower() functions"
e.g math.h is a file containing mathematical function.It contain "sqrt(), pow(), floor(), ceil(), sin(), cos()" functions.
2. Name of a program:- It is used to indicate the purpose of program.It indicate what is problem to be solved by program.It is given using comment operator at start of program.It is optional.
4.Declaration part:- This part is used to declare variables of different data types.Initialization of variable is also done in this section.By initialization , we assign starting value to variables.
5.Executable part:- This part follows declaration part.In this part set of statements performing various, functions are defined.There can be single statement or set of statements.Single statement can be written without curly brackets({}).Compound statements are are written using pair of curly brackets({}).
6.User defined function:- The function defined by user is called as user defined functions.These function are generally defined after main() function.There can be any number of user defined functions but there is only one main function.The body of these functions can be defined before main() function also.If body of functions is defined after main then prototype of function is defined above body of main() function.
7.Comments:-The comments are not necessary.But for good documentation these are added.Comment can be inserted anywhere in program.These are given by writing text between \* and * \.
Delimiters : Special type of symbols used for special purpose is called as delimiter.
e.g.
colon :
semi colon ;
parenthesis ( )
hash #
comma ,
square bracket []
SAMPLE OF A 'C' PROGRAM :-
#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c;
a=5;
b=6;
c=a+b;
printf("The value of c= %d",c);
getch();
}
OUTPUT :_
c=11
Download area.......
Download TCC
0 comments:
Post a Comment