multiple of 5

#include <iostream>

using namespace std;

int main()
int i=0;
while (i<=100)
if ((i/5)=)
return 0;

the part where i need to check for values divisible by 5 is imcomplete, please help me
Last edited on
Hi there,

Welcome to the forums. If you have a problem, please state it clearly and specifically. Just giving us code does not tell us much. Also, please put any code between [code][/code]-tags,for it to be more readable.

From looking at your code, I can tell this line will be causing you problems:

if ((i/5)=)

I suspect you are wanting to print all the multiples of 5 up to 100. The best way is to use the modulus operator, which returns you the remainder of the division of its left operand by its right operand:

7 % 5 = 2 (7/5 = 1, with 2 remainder)
10 % 5 = 0 (10/5 = 2, with no remainder)

So to check if a number is a multiple of 5:

if ((i % 5) == 0)

All the best,
Thanks a lot, it works great :)
Topic archived. No new replies allowed.