





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This is solution to assignment of Basic Unified Engineering course. It was submitted to Prof. Yasaar Verma at Jiwaji University. It includes: Robust, Algorithm, Integer, Division, Repeated, Subtraction, Quotient, Remainder, Precondition, Postcondition
Typology: Exercises
1 / 9
This page cannot be seen from the preview
Don't miss anything!






. -- Procedure to carry out robust division . -- Programmer: Jayakanth Srinivasan . -- Date Last Modified : April 17, . --------------------------------------------------------- . . with Ada.Text_Io; . with Ada.Integer_Text_Io; . use Ada.Text_Io; . use Ada.Integer_Text_Io; . . procedure Robust_Division is . X, . Y, . Q, . R : Integer; . Divide_By_Zero : exception; . . begin . loop . Ada.Text_IO.Skip_Line; . begin . -- get the dividend (X) . Ada.Text_Io.Put("Please Enter the X : "); . Ada.Integer_Text_Io.Get(X); . Ada.Text_Io.Skip_Line; . . -- get the divisor (Y) . Ada.Text_Io.Put("Please Enter the Y : "); . Ada.Integer_Text_Io.Get(Y); . Ada.Text_Io.Skip_Line; . . if Y = 0 then . raise Divide_By_Zero; . end if; . . --set the remainder to absolute value of X . R :=abs(X); . -- set quotient to zero . Q := 0 ; . -- while remainder is greater than absolute value of y . while R >= abs(Y) loop . -- deduct absolute value of y from the remainder . R := R - abs(Y) ; . -- increment the quotient . Q := Q + 1; . end loop; . . --ensure that the sign on the quotient is quotient . if (X<0) or (Y<0) then . if (X<0) and (Y<0) then . -- if both x,y are negative then remainder is negative . R := -1*R;
loop exit when Flag := True;
if A < 100 and B > 200 then if A > 50 then Sum := Sum +2; else Sum := Sum +1; end if; else if B < 300 then Sum:= Sum -1; else Sum := Sum -2; end if; end if;
end loop;