| Introduction to C |
| |
| A sample of C language program |
| |
| Example of C program to calculate area of circle: |
| |
 |
| |
| Explanation of above program : |
| |
| # is the preprocessor directive which commands that the content of file
should be included at the time of compilation. |
| |
| < stdio.h> is the header file which contains all input and output functions like scanf(), printf() which are frequently used in c programs. |
| |
| main() is the first function which is executed by a C program. |
| |
| 1. int a,r=5; -> This statement declares 2 variables a and r of type integer and r has been assigned a value of 5. |
| |
| 2. const pi=3.14; -> This statement declares pi as constant and value 3.14 has been assigned to it. |
| |
| 3. a = pi * r *r; -> This statement computes the area of circle and assign it to variable a |
| |
| 4. printf("%f",a); -> This statement prints the area of circle using printf function. |
| |
| 5. getch(); -> It is used to get character from user. |
| |
| Note: /* Any thing written within it is consider as comment statements. */ |
| |
| For Animated Presentation(With Voice) Click here |
| |
| |
|
| |
| |