Each of the following add and subtract one from their operan

Each of the following add and subtract one from their operands? Plus and minus ++ and -- binary and unary conditional and relational None of these is the output of the following code segment? 1 2 3 4 5 1 2 3 4 1 1 1 ... and on forever 2 3 4 5

Solution

++ and -- operator are used to add or subtract one element.

eg: x=1;

x++; x=2

x--; x=1

int n=1;

while(n<=5)

{

cout<<n<<\" \";

}

the output will be 1,1,1,1,...............infinity as no increment condition is given so

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

to correct the program

int n=1;

while(n<=5)

{

cout<<n<<\" \";

n++; // condition

}

o/p that is 1 2 3 4 5

 Each of the following add and subtract one from their operands? Plus and minus ++ and -- binary and unary conditional and relational None of these is the outpu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site