Back to Home & C
//Program to find addition of two numbers using pass by reference method
#include<stdio.h>
#include<conio.h>
int add(int *x,int *y);
void main()
{
clrscr();
int a,b,c,*p1,*p2;
printf("Enter two numbers\n");
scanf("%d%d",&a,&b);
p1=&a;
p2=&b;
c=add(p1,p2);
printf("addition=%d",c);
getch();
}
int add(int *x,int *y)
{
int *z;
*z=*x+*y;
return(*z);
}
-----------------------------------------------------------
Output :
Enter two numbers
3
4
addition=7
=========================================================================
Back to Home & C
//Program to find addition of two numbers using pass by reference method
#include<stdio.h>
#include<conio.h>
int add(int *x,int *y);
void main()
{
clrscr();
int a,b,c,*p1,*p2;
printf("Enter two numbers\n");
scanf("%d%d",&a,&b);
p1=&a;
p2=&b;
c=add(p1,p2);
printf("addition=%d",c);
getch();
}
int add(int *x,int *y)
{
int *z;
*z=*x+*y;
return(*z);
}
-----------------------------------------------------------
Output :
Enter two numbers
3
4
addition=7
=========================================================================
Back to Home & C
No comments:
Post a Comment