0

(I am being honest, it is an assignment that I have attempted)

I have a question/assignment that requires me to do a for loop that counts to a specific number (i am using 25) and skips every number that is (for example) divisible by 3.

I have tried this:

int o;
      for (o = 1; o <= 25; o++)
          {
              if (o % 3)
              continue;
              Console.WriteLine(o);
          }

My solution didn't work, nor did google help me out that much... I know the answer is super simple and I am just missing it somehow because I am tired.

Thanks in advance.

2
Contributors
2
Replies
12
Views
4 Years
Discussion Span
Last Post by <M/>
1

try

int o;
for (o = 1; o <= 25; o++)
{
    if (o % 3 != 0)
        Console.WriteLine(o);
}
Console.ReadLine();
Votes + Comments
Thanks!
0

Thanks tinstaafl!

It worked perfectly, I didn't realize I was missing !=0 in line 4.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.