+ 4
Quiz Rejected
//code contains out of scope syntax What is the output of this code? int i=0; int x=10; for (;i <x;i++,x--); cout <<x+i; can anyone please explain in detail what is wrong in it ?
9 Réponses
+ 17
This is probably due to the confusing statements in for loop syntax. The alternative which i suggest:
while (i < x)
{
i++;
x--;
}
cout << i+x;
+ 16
*shrugs*
Add more cookies to your codes? 🍪
+ 8
u r terminating the for loop with a semicolon lol😂
+ 4
isn't confusing code is what challenges us to think and quizes are meant for that else it is just a matter of speedy maths .
+ 2
i did that on purpose to make it challenging .
its answer is just
10
+ 1
COOKIES ??
I didn't get that .
Is that some kind of technical joke ?
0
come to think of it, the question is correct because it has a correct answer = 10.
- 1
/*
for (;i <x;i++,x--);
don't terminate the for loop with semicolon(;)
*/
int i=0;
int x=10;
for (;i<x;i++,x--)
cout <<x+i;
- 1
There is an error, you had put semicolon in the begging of the for statement, and you have a semicolon at the end of the for statement, after the bracket.