Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question with sample picture on how to solve Question 1 what function () does the following program compute? Give a precise definition. IF Xi #

Question with sample picture on how to solve image text in transcribed
image text in transcribed
Question 1 what function () does the following program compute? Give a precise definition. IF Xi # 0 GOTO E YY+1 IF X2 [A] 0 GOTO A Sample Programs Sample Programs Consider the following program [A] X+-X-1 The following program computes fx) x IF X 0 GOTO A IF Z 0 GOTOE What function does this program compute? t(x) = 1, if x 0 x-otherwise IF X 0 GOTO B What would we have to change if we wanted to compute the function f(x) ? Sample Programs Sample Programs In the previous example, he ines From now on we will use the macro GOTO L in our We know that we could always replace GOTO L wth its macro expansion to obtain a valid C program. IF Z 0 GOTO L were used to implement an instruction that we could Now remember the program computing the function f(x)x Although it computes its output correctly, it deletes (sets to zero) the original input. This is an undesirable behavior, so we should come up with an improved program GOTOL First, we make sure that Z has a nonzero value, and then the conditional branch (actualy, here t is an unconditional branch) is executed. Sample Programs Sample Programs A IF X O GOTOB The previous program justfies the introduction of a GOTOC Yu Y+ 1 GOTO A GOTO E x-X+1 B] X-X-1 Ve-V The execution of this macro will replace the contents of variable V by those of variable V without changing the contents of V However, there is one problem: The previous program could rely on the initial condition Y 0, which is not guaranteed for any variable V GOTO C Question 1 what function () does the following program compute? Give a precise definition. IF Xi # 0 GOTO E YY+1 IF X2 [A] 0 GOTO A Sample Programs Sample Programs Consider the following program [A] X+-X-1 The following program computes fx) x IF X 0 GOTO A IF Z 0 GOTOE What function does this program compute? t(x) = 1, if x 0 x-otherwise IF X 0 GOTO B What would we have to change if we wanted to compute the function f(x) ? Sample Programs Sample Programs In the previous example, he ines From now on we will use the macro GOTO L in our We know that we could always replace GOTO L wth its macro expansion to obtain a valid C program. IF Z 0 GOTO L were used to implement an instruction that we could Now remember the program computing the function f(x)x Although it computes its output correctly, it deletes (sets to zero) the original input. This is an undesirable behavior, so we should come up with an improved program GOTOL First, we make sure that Z has a nonzero value, and then the conditional branch (actualy, here t is an unconditional branch) is executed. Sample Programs Sample Programs A IF X O GOTOB The previous program justfies the introduction of a GOTOC Yu Y+ 1 GOTO A GOTO E x-X+1 B] X-X-1 Ve-V The execution of this macro will replace the contents of variable V by those of variable V without changing the contents of V However, there is one problem: The previous program could rely on the initial condition Y 0, which is not guaranteed for any variable V GOTO C

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning C# 2005 Databases

Authors: Karli Watson

1st Edition

0470044063, 978-0470044063

More Books

Students also viewed these Databases questions

Question

Explain the role that peer group dynamics play in hate crimes.

Answered: 1 week ago