0
Quiz with loop from 0 to 100
I take 1 hour to get the result for loop 100 time, it is not programming !!!!!!
8 Respostas
+ 10
for (int i = 0; i < 100; i++)
{
//codes
}
?
+ 9
@Chokri It would print all even numbers between 0 and 99
+ 2
Thank you for your remarks and answers.
But I think that we can skip this type (loops with N>10 ) of quiz.
+ 1
c++
+ 1
like this , what is the output in 15sec:
for(int i=0;i<99;i++)
{
if (i%2 == 0)
cout << i;
}
+ 1
I would say "between 0 and 98" but there are not real difference in this case 'cause 99 anyway is not an even number (but loop won't run with i=99). Just wanted to mind it for those who has just started.
+ 1
@Chokri ZAGROBA every time the loop runs it checks if i%2==0 which happens(=means) "if i is even" then... and then goes output cout << i; so this code outputs every even number as Hatsy Rei has said.
And then, I'm sure as... just very sure, question don't ask you to enter each number in output. :-) It could ask what is the last number in output (it's 98), how many numbers is printed (it's 50). And (sorry, but) all of this are easy questions that don't need you to iterate through it step by step. But sometimes there are questions with loops that needs you to iterate through some ten steps and usually those question are very hard to solve in given time. I'm still not sure if we should to collect such issues, discuss them here in Q/A sections, and then report some of them.
0
What language?