How to use function find the sum of two numbers in C language

Function

On this page

Function

Program to use Function Find the Sum of Two Numbers in C Language

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

Output

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