4 | Structure & Samples of C-Program
4.0 | Contents :
1. General Structure of C Program
2. Samples of C Programs
4.1 | General Structure of C Program :
include section main function { variable declaration; clrscr(; statements/expressions; getch(; return 0; } |
- Include Section : In this section, header files must be included. Which type of header files are included, this depends upon which type of funtions are used in the C program.
- Main Function : This function is always present in all the C programs. You can call it like this is the starter of every C program.
- Variable Declaration : Here, user declares the variables and these variables are only usable in this function i.e. variables declared are local variables.
- clrscr () : This function will clear the output screen before the execution of the program.
- Statements / Expressions : In this section, user can write valid C statements OR valid C expressions.
- getch() : This function is used to hold the screen until C program is not terminated.
- return 0 : This will terminate the execution of the program.
4.2 | Samples of C Programs :
Example 1 : | |
Input :
#include<stdio.h>
|
Output : Hello World ! |
Input :
#include<stdio.h>
|
Example 2.1 : |
Input :
#include<stdio.h>
|
Output : Character : A Integer : 34 Floating Point Number : 34.645000 |
|
Example 2.2 : |
Input :
#include<stdio.h>
|
Output : Character : AInteger : 34 Floating Point Number : 34.645000 |
|
Comments
Post a Comment