1. Create a 'for' loop that will display numbers: 100 90 80 70 60
2. Create a 'for' loop that will display all EVEN numbers from 1 to N. (N is a positive number entered by the user.)
3. Create a 'while' loop that will accept numbers but stops when it encounters a negative number.
#include <iostream>
using namespace std;
int main() {
int i,n;
// 1.
for (i=100; i>=60; i=i-10){
cout<<i<<" ";
}
// 2.
cout<<"\n\nEnter N: ";
cin>>n;
for (i=1; i<=n; i++){
if(i%2==0)
cout<<i<<" ";
}
// 3.
cout<<endl<<endl;
while(n>0){
cout<<"Enter N: ";
cin >>n;
}
return 0;
}
Comments
Leave a comment