C Language

June 9, 2023

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

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

by : Ajaj Khan

Quick Summary:

program to use function find the sum of two numbers in C language copy #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 […]