Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*C basic structure example
- to find sum of two numbers */ //documentation section
- #include<stdio.h> //Link section
- int total; //Global declaration section
- int sum(int,int); //Function declaration section
- void main() //Main section
- {
- int a,b;
- printf("\n Enter the two numbers : ");
- scanf("%d %d",&a,&b); /* taking two numbers as input*/
- total = sum(a,b); /* calling function.The value returned by the function is stored in total */
- printf("\n The sum of two numbers is : %d ",total);
- getch();
- }
- int sum ( int num1,int num2) //User defined section
- {
- int result; /* defining variable, its scope lies within function */
- result = num1 + num2 ; /*adding two numbers*/
- return (result) ; //definition section
- }
Add Comment
Please, Sign In to add comment