Answer to Question #290807 in C++ for Levi

Question #290807

Type a statement using srand() to seed random number generation using variable seedVal. Then type two statements using rand() to print two random integers between (and including) 0 and 9


1
Expert's answer
2022-01-26T12:55:01-0500
#include <iostream>
#include <ctime>


int main()
{
	// Variable for seed random number
	int seedVal;
	std::cout << "Enter seed value : ";
	std::cin >> seedVal;


	// Generation random numbers
	srand(seedVal);


	// Output integers numbers
	std::cout << "Integer 1 : " << rand() % 10 << std::endl;
	std::cout << "Integer 2 : " << rand() % 10 << std::endl;


	// Exit
	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