How can I create a c++ program to print the numbers between 1-50 which are divisible by 5&7? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can I create a c++ program to print the numbers between 1-50 which are divisible by 5&7?

29th Mar 2017, 3:32 AM
Ravi Yadav
2 Answers
+ 11
#include<iostream> using namespace std; int main(){ for(int I=1;I <= 50; I++){ if(I % 5 == 0 || I % 7 ==0) cout << I << endl; } }
29th Mar 2017, 4:07 AM
Mr.Robot
Mr.Robot - avatar
+ 3
To be a little facetious: #include<iostream> using namespace std; int main(){cout << 35 << endl;} Technically, this is the correct answer to the question you asked. If you were looking for a program to print all numbers between 1 and 50, which are divisible by 5 or divisible by 7, then go with Mr.Robot's answer.
29th Mar 2017, 4:39 AM
Tob
Tob - avatar