write a C++ statement that assigns a 4 digit random number between 1000 and 10000 as the value of the variable n
using namespace std;
#define MIN_RANDOM_NO 1000
#define MAX_RANDOM_NO 10000
main(void)
{
int n=0;
while(n<MIN_RANDOM_NO || n>=MAX_RANDOM_NO) n = rand();
cout<<"\n4-digits Random Number in between "<<MIN_RANDOM_NO<<" to "<<MAX_RANDOM_NO<<" = "<<n;
return(0);
}
Comments
Leave a comment