Answer to Question #249097 in Algorithms for pats

Question #249097

Given two numbers X and Y. Write a program to determine the difference between X and Y. If X – Y is negative, compute R = X + Y; if X – Y is zero, compute R = 2X + 2Y; and if X – Y is positive, compute R = X*Y. Print out the value of X, Y, and R.


1
Expert's answer
2021-10-09T15:50:47-0400
Start
   Declare variables X,Y,D,R
   D = X – Y
   if D<0 then
       R = X + Y 
   End if
   if D=0 then
      R = 2*X + 2*Y
   end if
   if D>0 then
      R = X*Y
   end if
   Print X
   Print Y
   Print R
Stop

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS