+ 3

My Challenge Question: What was the value of variable at the beginning?

Instead of ??? try to find out the start positive integer value of variable n in the code below, which outputs 247: int main(void) { unsigned int n=???, sum=0; for (unsigned int i=0; i<???; i++) { n+=2; sum+=n; } cout << sum; //outputs 247 return 0; } Please, explain your answer and notice if this question is difficult.

11th Jul 2017, 2:01 PM
Александр Громозонов
Александр Громозонов - avatar
11 ответов
+ 4
your question is too easy if it was meant to be like this... https://code.sololearn.com/coLGfAm8PP1H/?ref=app else add some more ingredients to make it harder!
11th Jul 2017, 3:20 PM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 3
hoooooo hoooooo I won against you Sir ! ho hoo
22nd Jul 2017, 5:58 AM
Muneeb Ahmed
Muneeb Ahmed - avatar
+ 3
Yes. Congratulations!😊 And what about this question?
22nd Jul 2017, 6:19 AM
Александр Громозонов
Александр Громозонов - avatar
+ 2
Instead of ??? must be integers. Starting value of n and exit value in loop for i could be different.
11th Jul 2017, 2:53 PM
Александр Громозонов
Александр Громозонов - avatar
+ 2
n=245 and i<1 is one of solutions. Sorry, I forgot to notice, that there is more than one iteration in this loop. Another solution is more interesting.
11th Jul 2017, 3:44 PM
Александр Громозонов
Александр Громозонов - avatar
+ 2
really sorry sir I dont know much about C++ and C# !!
22nd Jul 2017, 6:43 AM
Muneeb Ahmed
Muneeb Ahmed - avatar
+ 1
No, not 6.
11th Jul 2017, 2:38 PM
Александр Громозонов
Александр Громозонов - avatar
+ 1
Well... n=245 ... i<1 xD
11th Jul 2017, 3:12 PM
Andrés04_ve
Andrés04_ve - avatar
0
n=n
11th Jul 2017, 2:29 PM
AgentSmith
0
is that 6?
11th Jul 2017, 2:37 PM
Andrés04_ve
Andrés04_ve - avatar
0
is the limit of i the same value of n?
11th Jul 2017, 2:49 PM
Andrés04_ve
Andrés04_ve - avatar