Compile error: The name 'x' does not exist in the current context [closed]

2

I'm trying to do this exercise in C #, but every time I try to compile it points out the error:

  

The name i does not exist in the current context

Does anyone know how to solve this?

int N, a, b;

N = int.Parse(Console.ReadLine());
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());

for(int i = a; i <= b; i++);
{
    if(i % N == 0)
    {
        Console.WriteLine(i);
    }
}
    
asked by anonymous 03.07.2018 / 15:03

1 answer

5

You have to get the semicolon after% w / o%

for(int i = a; i <= b; i++); // <<-- Isso tá errado

It needs to look like this:

for(int i = a; i <= b; i++)
{
    if(i % N == 0)
    {
        Console.WriteLine(i);
    }
}
    
03.07.2018 / 15:06