For Loop Help!!!

Hewlett-packard 4x dvd module mpeg decod...
April 7, 2010 at 07:55:19
Specs: Windows 7
Write a c++ program to ask the user for two integers, first and last;
then write a 'for' loop that will print all integers in the range[first, last]
that leave a remainder of 3 when divided by 7
OR leave a remainder of 5 when divided by 11.
You program should NOT show the same number twice!

This is what I have so far...

#include <iostream.h>

using namespace std;

int main () {
int int1, int2;

cout << "Enter the first integer first: " << endl;
cin >> int1;

cout << "Enter the second interger last: " << endl;
cin >> int2;

for (int i=3;i<101;i+=7 || int i=5;i<101;i+=11 ) {
std::cout << i << " ";

return 0;

Im not quite sure what Im doing wrong... Any suggestions???

See More: For Loop Help!!!

Report •

April 7, 2010 at 08:53:16
for (int i=3;i<101;i+=7 || int i=5;i<101;i+=11 ) {
You seem to be confusing for's syntax with if's. Also, you're not using the range you get from the user.

Don't try to be fancy; you're in a beginner programming class. Just increment your loop by one, and do your modulus and testing then.

Report •
Related Solutions

Ask Question