daily pastebin goal
53%
SHARE
TWEET

Lektion 3: Uppgift 1

CarlBjorklund Oct 6th, 2017 (edited) 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
  2. with Ada.Text_IO; use Ada.Text_IO;
  3.  
  4. --Mata in fem heltal och summera dessa. Avänd underprogram och fält.
  5. procedure Upp1 is
  6.    
  7.    type Array_Int is
  8.      array(1..5) of Integer;
  9.  
  10.    procedure Inmatning(A: out Array_Int) is
  11.    begin
  12.       Put("Mata in fem heltal: ");
  13.       for I in 1..5 loop
  14.      Get(A(I));
  15.       end loop;
  16.       Skip_Line;
  17.    end Inmatning;
  18.    
  19.    procedure Summering(A: in Array_Int;Summan: out Integer) is
  20.    begin
  21.       Summan:=0;
  22.       for E in 1..5 loop
  23.      Summan:=A(E)+Summan;
  24.       end loop;
  25.      
  26.    end Summering;
  27.    X: Array_Int;
  28.    Y: Integer;
  29. begin
  30.    
  31.    Inmatning(X);
  32.    Summering(X,Y);
  33.    Put("Suman blev: ");
  34.    Put(Y,0);
  35. end Upp1;
RAW Paste Data
Top