Ticker

6/recent/ticker-posts

C language (Basic Structure)

BASIC STRUCTURE OF C  PROGRAM

To understand the basic structure of C language program, we have to observe a simple C program.

A SIMPLE C PROGRAM EXAMPLE
#include<stdio.h>
#include<conio.h>
void main()
{
printf("Welcome in the C programming world");
getch();
}

The above C program can be divide in the following blocks.

1. Preprocessor Directive 

2. Header Files

3. Void Keyword

4. Main Function

5. Curly Braces

6. Clrscr() Function

7. Printf() Function

8. Getch() Function


PREPROCESSOR DIRECTIVE
Preprocessor directives start with '#' sign and its uses are described below.
#define is used to define a macro in C programming language.
#include preprocessor directive is used to add system defined and user defined header files.


HEADER FILES
Header files are used to include system defined (built in library) functions in the C language programs and in the above program, there are two header files.
1. stdio.h (for printf() function)
2. conio.h (for clrscr() and getch() functions)


VOID KEYWORD
In the above program the void keyword is using  to block the main() function return value.


MAIN FUNCTION
The main function is like entrance gate for every C program.
Every C program's execution start from its main function.


CURLY BRACES
There are two types of curly braces ({ Opening brace, } Closing brace) in the programming language and these are used to define a functions and control statements like (If else, Else if, Switch, Loop) boundary.


CLRSCR FUNCTION
The clrscr() function is used to clear the output console window of C programming language.


PRINTF FUNCTION
The printf() function is used to print the given argument (message) in the output console window.


GETCH FUNCTION
getch() function is used to read a single character from the user at program run time.













Post a Comment

0 Comments