+ 2
Can Someone Pls. Explain Me The Output Of This Code.
Shouldn't The Outcome Be 1(Maybe?!?).Thanks For Answering. https://code.sololearn.com/cey92UK7Qx0c/?ref=app
7 Antworten
+ 7
#include <iostream>
using namespace std;
int main()
{
int x=1;
for(;x<6;x+=2)
{ x=x*x;
}
cout<<x;
1st loop=x=1//x=x*x=1//x=+2=3
2nd loop=x=3//x=x*x=9//x=+2=11
x<6 condition false loop end
result 11
+ 6
Ohh....Thanks SD....🙆
+ 5
no problem
+ 4
But why it prints the x in the incrementation brackets and not that variable x of the for loop block
+ 4
in loop block there is no cout.. after calculate x value its print after loops end..
+ 4
Again Thanks SD You Are Awesome And An Inspiration Too...Best Wishes😇😊
+ 3
it pleasure to me.. u too.. good luck