How to write while program using if also | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to write while program using if also

write a program to print no 1to 100 which is Divisible by 5 only

9th Jul 2017, 8:56 AM
Sugandh Shreshta
Sugandh Shreshta - avatar
4 Answers
0
int n = 1; while(n <= 100) { if(n % 5 == 0) Console.WriteLine(n); ++n; }
9th Jul 2017, 9:53 AM
erez
erez - avatar
0
thanks erez
9th Jul 2017, 10:18 AM
Sugandh Shreshta
Sugandh Shreshta - avatar
0
and we're I write readline after ++n;
9th Jul 2017, 10:20 AM
Sugandh Shreshta
Sugandh Shreshta - avatar
0
if you want to stop the console from closing place it after the closing curly bracelets of the loop .
9th Jul 2017, 10:25 AM
erez
erez - avatar