Output Writing – Three dimensions in structure passed by reference – CSKC
Sign In

Search

Solved Problem #CPP#5596    siteicon   siteicon  

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

TC++ #5596

 

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP


Share

Created: 22-Dec-2018 12:45 | Updated: 22-Mar-2026 20:17|