# Loop Question

Hewlett-packard 4x dvd module mpeg decod...
March 29, 2010 at 20:44:22
Specs: Windows 7
 Im not sure how to actually start the code... The code I have been doing keeps giving the incorrect output.... Write a c++ program containing a loop to print allthe integers from 1 to 100 that have a remainder ofthree (3) when divided by seven (7).I really need some suggestions on to how to do this code please!!!! Thanks!1

See More: Loop Question

#1
March 29, 2010 at 20:55:16
 I'm sure you know how to programme a loop.In order to do the mathematics you need to be looking at the Modulus function.Google will give you plenty of examples of how to use the Modulus function.Stuart

Report •

#2
March 29, 2010 at 21:07:30
 I have this so far:#include int main(){ int num; num = 1; while (num <= 100) cin >> num; if ( num % 7 == 3 ) { cout << num << " "; } return 0;}

Report •

#3
March 29, 2010 at 22:06:53
 modulo will work, but simple addition also will serve:#include int main() {int i;int j;for (i=0;i<100;i+=7) {j=i+3;cout<

Report •

Related Solutions

#4
March 29, 2010 at 22:46:47
 @nbraneIt could be simplified further:#include int main() { for (int i=3;i<101;i+=7) { std::cout << i << " "; } return 0; } Also is depreciated in c++, instead is the recommended header.

Report •

#5
March 29, 2010 at 22:52:20
 cee? that's exactly what i mean Lol!! good point about the logic, though, duh me! i have no clue which compiler i have... I remain clueless as to which thingeys work... I guess i should try to figure these things out. ;)

Report •

#6
March 29, 2010 at 23:28:35
 @nbraneI am in no way and expert on C/C++, I really consider myself an "advanced beginner". It can be quite difficult at first, especially when it comes to pointers and other memory related tasks(less so for C++).Really they just hasn't got the extra layer of abstraction most newer languages have, but you can create your own or use libraries.Hang in long enough and I will get a bit easier.BTW what are you using(possibly an IDE)?

Report •