C Language

June 6, 2023

How to use sum in C language

program to use sum C language


#include<stdio.h>
int sum(int x, int y);   /*Function declaration*/
int main()
{
    int a=10,b=20,k;
    k=sum(a,b);        /*Function call*/
    printf("%d\n",k);
    k=sum(4,5);       /*Function call*/
    printf("%d\n",k);
    k=sum(a+b,b*2);   /*Function call*/
    printf("%d\n",k);
    return 0;
}
int sum(int x,int y)  /*Function definition*/
{
    int s;
    s=x+y;
    return s;
}

output


30
9
70

by : Ajaj Khan

Quick Summary:

program to use sum C language copy #include&ltstdio.h> int sum(int x, int y); /*Function declaration*/ int main() { int a=10,b=20,k; k=sum(a,b); /*Function call*/ printf(“%d\n”,k); k=sum(4,5); /*Function call*/ printf(“%d\n”,k); k=sum(a+b,b*2); /*Function call*/ printf(“%d\n”,k); return 0; } int sum(int x,int y) /*Function definition*/ { int s; s=x+y; return s; } output 30 9 70