How to use sum of two numbers is functions in C language

Sum Functions

On this page

Sum Functions

Program to use Sum of two Numbers is functions in C language

#include <stdio.h>
int sum(int x, int y); /*Function declaration*/
int main()
{
  int a, b, s;
  printf("Enter values for a and b : ");
  scanf("%d%d", &a, &b);
  s = sum(a, b); /*Function call*/
  printf("Sum of %d and %d is %d\n", a, b, s);
  return 0;
}
int sum(int x, int y) /*Function definition*/
{
  int s;
  s = x + y;
  return s;
}

Output

Enter values for a and b : 12
6
sum of 12 and 6 is 18