Write a program in which a function is passed address of two variables and then alter its contents.




#include<iostream.h>
#include<conio.h>
class alter
{
public:
void altering(double *a,double *b);
};
void alter::altering(double *a,double *b)
{
cout<<"Altering in function altering of alter class a to 0 and b to 2 "<<endl;
*a=0;
*b=2;
}
void main()
{
clrscr();
double a,b;
alter obj;
cout<<"enter the value of a "<<endl;
cin>>a;
cout<<"enter the value of b"<<endl;
cin>>b;
obj.altering(&a,&b);
cout<<"IN MAIN FUNCTION THE VALUES ARE"<<endl<<"a is "<<a<<endl<<"b is "<<b<<endl;
getch();
}









Output:-  

Comments

Post a Comment