For part of a programming that I'm writing, I want to generate random numbers between the range of -1000 and 1000. My teacher never spent much time on the rand function, and I'm not quite sure how to specify a range like that. Any help would be greatly appreciated. Thanks!

int r1 = rand() ; //random number from [0 , RAND_MAX]
int r2 = rand() % 100; // random number from [0,100); Note doesn't include 100
int r3 = rand() % 100 + 1; //random number from [1,100]; Note includes 100
const int max = 100;
const int min = -100;
int r4 = rand() % (max - min) + min; // random number between [min,max)

When you want to look up a function, you can see examples here. Bookmark it if you need to. Its a good reference

int r1 = rand() ; //random number from [0 , RAND_MAX]
int r2 = rand() % 100; // random number from [0,100); Note doesn't include 100
int r3 = rand() % 100 + 1; //random number from [1,100]; Note includes 100
const int max = 100;
const int min = -100;
int r4 = rand() % (max - min) + min; // random number between [min,max)

When you want to look up a function, you can see examples here. Bookmark it if you need to. Its a good reference

Thanks! The example worked well! I figured it out now.

int r1 = rand() ; //random number from [0 , RAND_MAX]
int r2 = rand() % 100; // random number from [0,100); Note doesn't include 100
int r3 = rand() % 100 + 1; //random number from [1,100]; Note includes 100
const int max = 100;
const int min = -100;
int r4 = rand() % (max - min) + min; // random number between [min,max)

When you want to look up a function, you can see examples here. Bookmark it if you need to. Its a good reference

How do i mark a thread solved? I'm relatively new here :p

INGGRIS
How to connect device scanner with visual basic, its analogy I made button scan in vb and typing button scan in press scanner live and walk .. how? Help ...

Greetings,
I have been trying to figure this out for hours with no avail. Basically I need to print out user input as Initial value, ASCII(char), ASCII(int), and Hex. I ...