+ 1

C++ I am try to get it to output every number divisible by 3 up to 20.

#include <iostream> using namespace std; int main() { //change the code int num = 3; while(num<=20){ cout<<num<<endl; num*=3; } return 0; }

17th Sep 2021, 9:38 AM
Mando
Mando - avatar
4 Answers
+ 3
Try num+=3 instead of num*=3
17th Sep 2021, 9:49 AM
Coding Cat
Coding Cat - avatar
+ 2
Oh wow it was that easy lol
17th Sep 2021, 9:50 AM
Mando
Mando - avatar