Write a program to add two numbers using functions accept, add, display using call by value and call by reference.
/* Write a program to add two numbers using functions accept, add, display using
call by value
and call by reference.*/
#include
<stdio.h>
void
accept(int *,int *);
int
add(int,int);
void
display(int,int,int);
void main()
{
int a,b,c;
accept(&a,&b);
c=add(a,b);
display(a,b,c);
getch();
}
void
accept(int *x,int *y)
{
printf("Enter the first number : ");
scanf("%d",x);
printf("Enter the second number :
");
scanf("%d",y);
}
int add(int
x,int y)
{
int z;
z=x+y;
return z;
}
void
display(int x,int y,int z)
{
printf("The sum of %d and %d is %d\n",x,y,z);
}
Comments
Post a Comment