Powered by Blogger.

C program to add two numbers using function

#include<stdio.h>
 
long addition(long, long);
 
main()
{
   long first, second, sum;
   printf("Enter two numbers : \n");
   scanf("%ld%ld", &first, &second);
 
   sum = addition(first, second);
 
   printf("\n Sum is : %ld\n", sum);
 
   return 0;
}
 
long addition(long a, long b)
{
   long result;
 
   result = a + b;
 
   return result;
}

/*
Output :
Enter two numbers : 
5
3
 Sum is : 8
*/