Write a program to generate all the even numbers lying between 1 and 20 using while loop in C++
Answers
Answered by
8
Answer:
#include <iostream>
using namespace std;
int main() {
int i=2;
while(i<=40){
cout<<i<<endl;
i+=2;
}
return 0;
}
Hint:-
- Initialise I=2
- Open while loop with condition I<=40
- print I
- increase I by 2
- close while
- Yay! you made it!!
Attachments:
Answered by
0
Attachments:
Similar questions