Question 0-1

Complete the following Ada program to read 30~numbers from the user into an array and then echo back to the screen all that exceed 50.

with Text_IO; use Text_IO;
procedure Print_Large is
    package Int_IO is new Integer_IO(Integer); use Int_IO;


begin




end Print_Large;

Solution

with Text_IO; use Text_IO;
procedure Print_Large is
    package Int_IO is new Integer_IO(Integer); use Int_IO;
    Nums : array (1..30) of Integer;
begin
    for I in Nums'Range loop
        Get(Nums(I));
    end loop;
    for I in Nums'Range loop
        if Nums(I) > 50 then
            Put(Nums(I)); New_Line;
        end if;
    end loop;
end Print_Large;

Back to Quiz 0