if theres a possibility of typing up the program, and making it clear as posssib
ID: 3884096 • Letter: I
Question
if theres a possibility of typing up the program, and making it clear as posssible that would be great
In Class Assignment 2 Write a small program in Ada that squares numbers stored in an 1. Declare an array called nums. 2. Print the contents of the array. 3. Square each element of the array. 4. Print the contents of the array again. This is a sample output: Current Array 1 4 Squares 4 9 25 Compile your work on an online compile like: http:// rextester.com//ada online_compiler or https://www.idoodle.com/execute-ada-onlineExplanation / Answer
-- This program illustrates square of an array elements
--
with ada.text_io; use ada.text_io;
with ada.integer_text_io; use ada.integer_text_io;
procedure hello is
MaxSize: Constant Integer := 5;
type IntArray is array (1 .. MaxSize) of Integer;
nums: IntArray;
begin
-- Fill the array by reading MaxSize integers
for i in nums'range loop
nums(i) := i;
end loop;
-- Print the array
put("Current Array");
new_line;
for i in nums'range loop
put(nums(i));
end loop;
new_line;
-- Update the array by square of the each element of the array
for i in nums'range loop
nums(i) := nums(i) ** 2;
end loop;
-- Print the squared array
put("Squares");
new_line;
for i in nums'range loop
put(nums(i));
end loop;
end hello;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.