0

You are given a program that outputs all the numbers from 0 to 20. Change the code to make it output only numbers that are mult

You are given a program that outputs all the numbers from 0 to 20. Change the code to make it output only numbers that are multiples of 3. I want it's solution in C++.

2nd Nov 2020, 9:52 PM
Horilal S Nirmalkar
Horilal S Nirmalkar - avatar
12 ответов
+ 4
Try this: for(int num=0;num<=20;num++) { if(num%3==0) { cout<<num<<endl; }; };
2nd Nov 2020, 11:35 PM
CouldntBeBothered.py
CouldntBeBothered.py - avatar
+ 3
if (number%3==0): cout<<number just to tell you it's a hint(more of an actual solution) ,do not use Q&A for asking codes tho ,post what you have tried and format your question properly to ask if you have a certain doubt related about what you can't really understand
2nd Nov 2020, 9:53 PM
Abhay
Abhay - avatar
+ 2
int num=0 While (num<20){ Cout << num; num=(num+1)*3; } This is my attempt But its out are 3 and 12 But the expected outs are 3,6,12
2nd Nov 2020, 10:01 PM
Horilal S Nirmalkar
Horilal S Nirmalkar - avatar
+ 2
try this #include <iostream> using namespace std; int main() { //change the code int num = 0; while(num<=20 ){ cout<<num<<endl; num+=3; if(num==0){ continue; } } return 0; }
26th Jun 2021, 11:43 AM
Chinmay Anand
Chinmay Anand - avatar
+ 2
Try This! CHEERS!! #include <iostream> using namespace std; int main() { int num; for(num=0;num<=20;num++) { if(num%3==0 && num!=0 ) { cout<<num<<endl; } } return 0; }
7th Sep 2021, 6:43 AM
Chalat Rahul
0
try this ,its easy while(number<=20 ) { if(num%3==0 && number!=0) cout<<number<<endl; number+=3 }
26th May 2021, 1:19 PM
Omar Mohammed Saad
0
int num = 0; if(num +=3 ){ while ( num <= 20){ cout<<num<<endl; num+=3;} } return 0; }
29th May 2021, 9:22 AM
Dhawa
0
#include <iostream> using namespace std; int main() { int num = 3; while(num<=20){ cout<<num<<endl; num+=3; } return 0; }
6th Dec 2021, 5:26 PM
Rather Firdous
Rather Firdous - avatar
0
#include <iostream> using namespace std; int main() { //change the code int num = 3; while(num<=20){ cout<<num<<endl; num+=3; } return 0; }
11th Dec 2021, 6:26 PM
amandeep
amandeep - avatar
0
#include <iostream> using namespace std; int main() { //change the code int num = 0; while(num<=20){ if(num==0){ cout<<endl; } else{ cout<<num<<endl; } num=num+3; } return 0; } Good Luck
25th Jan 2022, 11:31 AM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar
0
The provided code stores the value 7 in a variable, and outputs it. T
1st May 2022, 9:28 AM
Perez B