C Structure Example With Explanation By Program

C Structure Example With Explanation - Program To Add 2 Numbers Explain
Get Our Latest Interview Questions: Aptitude, Reasoning, English, GD, HR-PI

Simple Program to add 2 number In C:

1.// Program to add 2 numbers.    - Documentation Section 
2.#include<stdio.h>    - Link Section 
3.#include<conio.h> 
5.void main()      - Main Function 
6.{ 
7.Int a,b,c;      // 
8.a=2, b=3;    // Declaration Part 
9.c=a+b;                                                // 
10.printf(“Addition of 2 no:%d”,c);     // Executable Part 
11.getch(); 
12.}

Explanation of above program:
In line 1 written after // is called comment section. Here we write the name of code or description of code what we are writing. 
In line 2nd #include<stdio.h>  and 3rd #include<conio.h> we had written,  here #include is a preprocessor directive that tell the c preprocessor to look for the mentioned header file like: stdio.h , conio.h or etc. in the location where #include directive includes. Stdio stands for standard input output, it handle all input output operation. and conio stands for console input output, it handles all console application, and .h is the extension of header file. Header files are saved in a subdirectory called include in location: c:\tc\include. 
line 4 is a global declaration part here we declare all variables or function which we are using in our program any where.   
Line 5 void main() – this is the main function part, in between { and } braces we write our code or instruction we need to give to computer.  
Line 7 written int a,b,c; - here int is a data type (We discuss in next page) and a,b,c are three variables (We discuss in next page).  
In line 8. a=2, b=3 we have written, here we are giving the value of a & b. 
Line 9 we written c=a+b; here we add 2 numbers. This is the program to add 2 numbers. 
In line 10 we print the output (that added in line 9) and printf is used for printing the value (discuss later). 
In line 11 getch() this is used to hold the output screen so that we can see the result or output. Without getch our output screen will display only for few seconds and in this much time we can’t see the output.

Hence The Output Of Above Program is "Addition of 2 no:5"

Expert Review: In the above program you can learn how to write c program, and explanation of each words, why we are writing. It is very much important to know why we are writing these words in our c program. I Hope you understand each line if you have query then please comment on facebook comment box, we will try to solve your query. 

 Enter Your Email Address To Get Our Latest Programming Updates In Your Mail / Subscribe Our Updates In Your Mail:

Labels: ,