C Language

June 7, 2023

How to use find the sum of two numbers in C Language

Program to use find the sum of two numbers 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 :5
4
sum of 5 and 4 is 9

Tags:

by : Nadeem Khan

Quick Summary:

Program to use find the sum of two numbers in C Language copy #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, […]