# Help

This is a discussion on Help within the C++ Programming forums, part of the General Programming Boards category; Hello, first of all i must say that i'm new in programming and especially in c++.also i m sorry for ...

1. ## Help

Hello,
first of all i must say that i'm new in programming and especially in c++.also i m sorry for my bad english..i read somewhere for function rand and i have some questions about that.i read that to find random numbers the type is x=low+rand()%(high-low+1).That i get it but how i can to have some exceptions.For exaple to find random numbers between -10 and 10 apart of 0...What i did was to wrote x=rand()%21-10;
x!=0;
but still appeared the 0 and i don t know what to do.

2. Code:
```x = rand() % 20;
if (x < 10)
{
x -= 10;
}
else
{
x -= 9;
}```
or
Code:
```do
{
x = rand() % 21 - 10;
} while (x == 0);```

3. Originally Posted by DRK
Code:
```x = rand() % 20;
if (x < 10)
{
x -= 10;
}
else
{
x -= 9;
}```
or
Code:
```do
{
x = rand() % 21 - 10;
} while (x == 0);```

Thank you very much!!!What was my mistake??

4. What was your actual code?