Output writing – forming expression within cout – CSKC
Sign In

Search

Solved Problem #CPP#5345    siteicon   siteicon  

Problem Statement - Output writing – forming expression within cout

Write output of the following code. Assume that related header files are included.

int main()
{
  int a=10,b=13,c;
  cout<<(c=a+b/a)<<" ";
  cout<<(a=b+c);
  return 0 ;
}

Solution

TC++ #5345

 

×

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

Notes

int a=10,b=13,c;
Here integer variable a is initialised with 10 and b with 13 but c is just declared.

cout<<(c=a+b/a)<<” “;
In this expression (c=a+b/a) would be evaluated first before printing. b/a would be one as 13/10 would be 1 (being only integer portion remaining. a+b/a would thus become 11. 11 would now be saved to c and then printed.

cout<<(a=b+c);
Since c has become 11 so b+c will become 13+11 = 24. This would be saved to a now and then printed.


Share

Created: 8-Dec-2018 23:36 | Updated: 22-Mar-2026 20:17|