Final answer:
To create a raptor program that asks the user to enter 10 numbers into an array and display all the numbers, the smallest, and the largest, follow these steps.
Step-by-step explanation:
To create a raptor program that asks the user to enter 10 numbers into an array and display all the numbers, the smallest, and the largest, you can follow these steps:
- Start by initializing an empty array with a size of 10.
- Use a for loop to iterate 10 times and prompt the user to enter a number each time. Store each entered number in the array.
- After taking input, iterate through the array and display all the numbers.
- To find the smallest and largest numbers, initialize variables 'smallest' and 'largest' with the first number in the array.
- Loop through the array again and compare each element with the current 'smallest' and 'largest'. If an element is smaller than 'smallest', update 'smallest'. If an element is larger than 'largest', update 'largest'.
- Finally, display the 'smallest' and 'largest' numbers.
Here's an example of how the program might look:
DECLARE
numbers: array[10] of real;
smallest, largest, num: real;
BEGIN
FOR i in 1..10 DO
WRITE "Enter a number: ";
READLN num;
numbers[i] := num;
ENDFOR
FOR i in 1..10 DO
WRITE numbers[i], " ";
ENDFOR
smallest := numbers[1];
largest := numbers[1];
FOR i in 2..10 DO
IF numbers[i] < smallest THEN
smallest := numbers[i];
ENDIF
IF numbers[i] > largest THEN
largest := numbers[i];
ENDIF
ENDFOR
WRITE "
Smallest number: ", smallest;
WRITE "
Largest number: ", largest;
END.