Find the output of the cpp program

What is the output of below code?

1
2
3
4
5
6
7
8
#include "iostream"
using namespace std;
int main()
{
    int i;
    i = 1 + ( 1, 4, 5, 6, 3);
    cout<<i;
}

a) 4
b) 7
c) compile time error
d) no output

The correct answer for this question is b)7 if we perform the arithmetic operation with in parenthesis the largest number from the set is taken for computation of output

Arun

4 thoughts on “Find the output of the cpp program

  1. Your answer is wrong dude.Output would be 4…Just try to compile and run the code…..

  2. @Aryan thanks for pointing out the mistake it takes the last number in the parenthesis for evaluation

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in