Answer to Question #185973 in C++ for shuvo

Question #185973

write a C++ statement that assigns a 4 digit random number between 1000 and 10000 as the value of the variable n


1
Expert's answer
2021-04-29T05:41:13-0400
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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS