fork download
  1. with Ada.Text_IO; use Ada.Text_IO;
  2. with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
  3.  
  4. procedure Add_Numbers_Alt2 is
  5. A, B, Sum : Integer;
  6. begin
  7. -- Input A: prompt and number on same line
  8. Put("Enter A: ");
  9. Get(A);
  10. Put(A); -- prints A right after reading
  11. New_Line;
  12.  
  13. -- Input B: prompt and number on same line
  14. Put("Enter B: ");
  15. Get(B);
  16. Put(B); -- prints B right after reading
  17. New_Line;
  18.  
  19. -- Compute sum
  20. Sum := A + B;
  21.  
  22. -- Output result
  23. Put(A);
  24. Put(" + ");
  25. Put(B);
  26. Put(" = ");
  27. Put(Sum);
  28. New_Line;
  29. end Add_Numbers_Alt2;
  30.  
Success #stdin #stdout 0.01s 5288KB
stdin
2
2
stdout
Enter A:           2
Enter B:           2
          2 +           2 =           4