RETURNING MULTIPLE VALUE IN FUNCTION THROUGH POINTERS
void func(int *px,int *py); //prototype
void main(void)
{
{
int x,y;
func(&x,&y);
printf("x=%d y=%d",x,y);
}
void func(int *px,*py)
{
*px=6;
*py=7;
}
OUTPUT:
OUTPUT:
x=6 y=7
-----xx------------------------x----------------------x-------------------x-------------
-----xx------------------------x----------------------x-------------------x-------------
#include<iostream.h>
#include<conio.h>
int op(int x,int y,int &l,int & m)
{
int c;
c=x+y;
l=x-y;
m=x*y;
return c;
}
void main()
{
int a,b,*p,*q;
cin>>a>>b;
cout<<" "<<op(a,b,*p,*q);
cout<<*p;
cout<<*q;
getch();
}
No comments:
Post a Comment