Answer to Question #168220 in C++ for sara

Question #168220

Write a program that prints:

(a) all the even numbers between 1 and 100.

(b) all the odd numbers between 1 and 100.

(c) all multiples of 3 between 1 and 100.


1
Expert's answer
2021-03-04T07:40:21-0500
#include <iostream>
using namespace std;
int main(){
    cout<<"All even numbers between 1 and 100\n";
    for(int i = 1; i <= 100; i++){
        if(i % 2 == 0){
            cout<<i<<" ";
        }
    }
    cout<<"\n\nAll odd numbers between 1 and 100\n";
    for(int i = 1; i <= 100; i++){
        if(i % 2 !=0){
            cout<<i<<" ";
        }
    }
    cout<<"\n\nAll multiples of 3 between 1 and 100\n";
    for(int i = 1; i <= 100; i++){
        if(i % 3 == 0){
            cout<<i<<" ";
        }
    }

    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