- 2

Write a program using for loop that prints even numbers from 0 to 20

7th Mar 2017, 11:35 AM
Nouman khan
Nouman khan - avatar
4 Respostas
0
Is this a question or an assignment? Learn how to specify the steps in your loop or use the modulus operator to determine if a number is even.
7th Mar 2017, 12:02 PM
Anthony Vanover
Anthony Vanover - avatar
0
two ways: 1st int x; for ( x=0; x <= 20; x = x+2 ) cout<< "This is a even number " << x << ".\n"; } 2nd more optimazed for ( x=0; x <= 20; x = x+1 ) if (x % 2 = 0) cout<< "This is a even number " << x << ".\n"; }
7th Mar 2017, 12:31 PM
Meher Jebali
Meher Jebali - avatar
0
This is Q
18th Dec 2022, 6:43 AM
Hunain Dar
Hunain Dar - avatar
- 1
for(int i=0;i<=20;i=i+2) Then print i
7th Mar 2017, 11:58 AM
Meharban Singh
Meharban Singh - avatar