- 3

What is the output of following code

int count = 1; for(int i=0;i<=99;i++){ for(int i=0;i<=99;i++){ count++;}} cout<<count;

14th Sep 2017, 1:41 PM
BINDUSHREE.M.V
BINDUSHREE.M.V - avatar
5 Answers
+ 9
There is a code playground for it Run it there ans : 10001 starting count 1 iterations for one loop =100 for both loops = 100*100 total=10000+1 =10001
14th Sep 2017, 1:46 PM
P R
P R - avatar
+ 6
Just lazy to run code? The answer is 10001!
14th Sep 2017, 1:45 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
Why not just run it and see for yourself? This website has the "Code Playground" that you can test from. https://www.sololearn.com/Codes/ Anyways, basically you have 100 iterations in the first loop, and 100 for each one of those 100. So, 100 * 100 = 10000. Count started as 1, so it'd be 10001 I believe.
14th Sep 2017, 1:48 PM
AgentSmith
+ 2
2 nested loops of 100-> 100^2=10000 Add to initial value, 10000+1=10001. Code ayground is here for a reason
14th Sep 2017, 1:45 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Thanks for one and all, who have posted the answer, from now I will try it on code playground, I doesn't knew about that, so thanks all of you
14th Sep 2017, 1:54 PM
BINDUSHREE.M.V
BINDUSHREE.M.V - avatar