Answer to Question #323561 in C++ for rem

Question #323561

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.


1
Expert's answer
2022-04-04T16:11:34-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS