example for call by reference:
#include<stdio. h>
main()
{
int add(int*,int*);
int sum,n1,n2;
printf("enter the no.s");
scanf("%d%d",&n 1,&n2);
sum=add(&n1,&n2 );
printf("%d",sum );
}
int add(int *x,int *y)
{
int sum;
sum=*x+*y;
return sum;
}
the difference: in call by value we r passing...
User Profile
Collapse
Profile Sidebar
Collapse
kiara
Last Activity: Jan 22 '12, 07:58 PM
Joined: Jan 22 '12
Location:
-
example for call by value:(with return and argument type)
#include<stdio. h>
main()
{
int add(int,int);
int n1,n2,sum;
printf("enter two no's");
scanf("%d%d",&n 1,&n2);
sum=add(n1,n2);
printf("%d",sum );
}
int add(int x,int y)
{
int sum;
sum=x+y;
return sum;
}Leave a comment:
No activity results to display
Show More
Leave a comment: