C Language

June 9, 2023

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


#include <stdio.h>
int sum(int x, int y) /*function definition*/
{
    int s;
    s = x + y;
    rextturn s;
}
int main(void)
{
    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;
}

Output


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

by : Nadeem Khan

Quick Summary:

copy #include &ltstdio.h&gt int sum(int x, int y) /*function definition*/ { int s; s = x + y; rextturn s; } int main(void) { 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, […]