alien_fx_fiend

C Sum Of 2 (sample code)

Jun 28th, 2019
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. /*C basic structure example
  2. to find sum of two numbers */    //documentation section
  3.  
  4. #include<stdio.h>        //Link section
  5.  
  6. int total;            //Global declaration section
  7. int sum(int,int);        //Function declaration section
  8. void main()            //Main section
  9.  {
  10.   int a,b;
  11.   printf("\n Enter the two numbers : ");
  12.   scanf("%d  %d",&a,&b);    /* taking two numbers as input*/
  13.   total = sum(a,b);      /* calling function.The value returned by the function is stored in total */
  14.   printf("\n The sum of two numbers is : %d ",total);
  15.   getch();
  16.  }
  17.  
  18.  int sum ( int num1,int num2)    //User defined section
  19.  {
  20.   int result;          /* defining variable, its scope lies within function */
  21.   result = num1 + num2 ;   /*adding two numbers*/
  22.   return (result) ;        //definition section
  23.  }
Add Comment
Please, Sign In to add comment