Header Ads Widget

Ticker

6/recent/ticker-posts

functions program in c :- 2

 Program 2: Design a function which takes two integer values and make addition and return addition to calling function. (C function with arguments and with return value or return type)


#include< stdio.h >

#include< conio.h >

void main ()

{

int a,b,c;

int sum (int ,int);

/only mentioning data type is also allowed in function prototype/

printf(“\n Enter two number ”);

scanf(“%d %d ”& a, &b);

c=sum (a, b);

printf(“\n Addition is =%d ”,c);

}

int sum (int a, int b)

{

int c;

c=a + b;

return c;

/*returning ‘c’ value which is of integer data type so data type of sum() is integer */

}


Output:

Enter two number

21

31

Addition is =52

Post a Comment

0 Comments