c program to demonstrate function with argument

Description


This program demonstrates function with arguments. The program uses a function add() with thee arguments x, y and z. The variable sum which is declared inside the function finds the sum of the values passed to these arguments and the result is returned.  The statement d=add(a,b,c); calls the function, the values of a, b and c is read as input form the user.

Program


#include<stdio.h>

#include<conio.h>

int add(int x,int y,int z);

void main()

{

clrscr();

int a,b,c,d;

printf("Enter the three numbers");

scanf("%d%d%d",&a,&b,&c);

d=add(a,b,c);

printf("Sum is %d",d);

getch();

}

int add(int x,int y,int z)     //function definition

{

int sum;

sum=x+y+z;

return(sum);

}

No comments: