Problem Statement - Output Writing – Three dimensions in structure passed by reference
Write down the output of the program.
struct three_d{int x,y,z;};
void movein(three_d &t,int step=1)
{
t.x+=step; t.y-=step; t.z+=step;
}
void moveout(three_d &t,int step=2)
{
t.x-=step; t.y+=step; t.z-=step;
}
int main()
{
three_d t1={10,20,5},t2={30,10,40};
movein(t1);
moveout(t2,5);
cout<<t1.x<<","<<t1.y<<","<<t1.z<<endl;
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;
movein(t2,10);
cout<<t2.x<<","<<t2.y<<","<<t2.z<<endl;
return 0;
}
Solution
Created: 22-Dec-2018 12:45 | Updated: 22-Mar-2026 20:17|
