Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
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
The code has been copied automatically for you in the clipboard. After that open any of the service and press cntrl-v to paste in the given code area. Needs a bit of tweaking as per the link.
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.