Problem :
Even Numbers
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Write a program that prints all even numbers between 1 and 100, including them if it is the case.
Input
In this extremely simple problem there is no input.
Output
Print all even numbers between 1 and 100, including them, one by row.
Sample Input | Sample Output |
2 4 6 ... 100 |
Solution:
#include <stdio.h>
int
main() {
int
i=1;
while
(i<100)
{
i++;
while
(i%2==0)
{
i++;
printf
(
"%d\n"
,i-1);
}
}
return
0;
}
No comments:
Post a Comment