Question: 3. Write a program to find the largest and second largest of 10 random numbers. Declare variables. Seed the random number generator with the time

 3. Write a program to find the largest and second largest

3. Write a program to find the largest and second largest of 10 random numbers. Declare variables. Seed the random number generator with the time of day. Initialize the variables for largest and second largest. On each pass through a for loop .Generate a random integer between 1 and 50 and print it. Check to see if it is larger than the maximum. If it is a new maximum, reassign the second largest. If it is not a new maximum, check to see if it is larger than the second largest. Upon exiting the loop, print the largest and second largest values

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!