for loop that iterates 10000 times and outputs a dot every 100 iterations?

hi so I'm trying to do this challenge(in the title) I have an idea of how to use the for loop. But I'm lost on how I'm going to output a dot every 100 iterations using modulo. I'd like to know how to do this using modulo.
Last edited on
here is a example using mod 5


1
2
3
4
5
6
7
8
9
10
11
    // for loop running 50 times
    for(int i = 0; i < 50; i++){
        // if i mod 5 is equal to zero
        if(i%5 == 0){
            // print out a dot and the value of 5
        cout << "." << " i = " << i << endl;
        }

    }

Yup, and here is exactly (I suppose) what you asked for:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

int main()
{
	for (int i = 1; i < 10000; i++)
	{
		if (i % 100 == 0)
		{
			std::cout << ".";
		}
	}

	std::cin.get();
	return 0;
}
maybe a for loop with an if statement that test if the variable of the for loop is modulus of 100 == 0 print " . ". Else continue. remember to make sure all of this in the scope of the for loop. Let me know if this works... Also if you show the code it helps us see where your going wrong.

PLEASE use the following resources to define how to apply your code to the form:

Either
http://www.cplusplus.com/articles/jEywvCM9/
or
http://www.cplusplus.com/articles/z13hAqkS/

PLEASE
Especially if it doesn't work. Note that this is only an idea if it doesnt work show the code and will trouble shoot or rethink other possible solutions.

*** Im leaving out a few basic details for you to try and figure out... Any more questions..."Show the code please"
Last edited on
i thought about using the if statement but I just couldn't figure out the condition. But now it's pretty clear to me. the condition is if( i%100==0) because every number that divides evenly by 100 should leave 0 remainder. I get it now. Thanks everyone!
Topic archived. No new replies allowed.