The programmer intends for this pseudocode to display three random numbers in the range of 1 through 10. Locate the error and clearly explain the error.
// This program displays three random numbers in the range of 1 through 10. Declare Integer count Declare Real value
// Display three random numbers.
For count = 1 To 5 Step 2
Set value = count
Display random(10, 1)
End For
// This program displays three random numbers in the range of 1 through 10.
Declare Integer count // this line declares count as integer
Set count = 1 //initialize the count to 0, so that it can be incremented upon the count
Declare Real value //this line declares value as real number
// Display three random numbers.
For count = 1 To 3 Step 2 //The error was here, we should run the for loop 3 times, but in psuedo code it was 5
Set value = random(10,1) //set the random value to a value in the range 1->19
Display value //display the value(obtained in previous step)
Set count = count + 1 //increase the count iterator, which is used as the iterator in for loop
End For
Get Answers For Free
Most questions answered within 1 hours.