Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Friday, May 20, 2011

C32 : Addition of two numbers using pass by reference method

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: