HELP! MUST USE BARE BONES PROGRAMMING ONLY! A. Write a Bare Bones program that t
ID: 3770731 • Letter: H
Question
HELP! MUST USE BARE BONES PROGRAMMING ONLY!
A. Write a Bare Bones program that takes as input a value for X and places 4 times the value of X into the value of Z. The value of X should be unchanged at the end of the program. Note that your program should NOT place a value into X to start. You may assume that the value of X has already been set just before your program runs.
B. Write a Bare Bones program that takes as input two variables X and Y. (Again, assume these values are set before your program begins to execute.) Your program should place a 0 in the variable Z if the variable X is less than or equal to Y, and your program should place a 1 in the variable Z if the variable X is greater than Y.
Explanation / Answer
Program 1:
clear Z;
incr Y;
incr Y;
incr Y;
incr Y;
while X not 0 do;
clear W;
while Y not 0 do;
incr Z;
incr W;
decr Y;
end;
while W not 0 do;
incr Y;
decr W;
end;
decr X;
end;
Program 2:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.