Answer to Question #283750 in C++ for Collay

Question #283750

4. A Shorter Three

by CodeChum Admin


Numbers in threes are awesome! But the one last time was too lengthy to look at, so I just want to view it in a shorter but still readable format.




You okay with this task?






Instructions:


Print out all numbers from 1 to 100 that is divisible by 3 using a for loop just like the last problem, but this time, with each number only separated by the space like that of the sample output.

Output


A line containing integers divisible by 3 separated by a space.


3·6·9·12·15·18·21·24·27·30·33·36·39·42·45·48·51·54·57·60·63·66·69·72·75·78·81·84·87·90·93·96·99


1
Expert's answer
2022-01-02T02:23:46-0500
#include <iostream>
using namespace std;
int main(){
    for(int i = 1; i <= 100; i++){
        if(!(i % 3)){
            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