Control Structures and Subroutines I A while loop whose cond

Control Structures and Subroutines

I. A while loop whose condition is not made false is called an infi nite loop. However, it is infinite, in the sense of continuing to run forever, only in theory. The loop will stop at some point. Why? 2. To evaluate the if statements in this question below, assume that a Print statement simply prints whatever is in quotes after it. The phrases after a semicolon in the third code fragment are comments and are meant to explain the code. Also assume the following variables have the values give A=5 ·C =7 For each pseudocode fragment below, write what would be printed in the case of the values given above. (a) If A D then Print \"the first thing (d) If A 5 then if B C then Print \"the first thing.. else Print \"the second thing\" else Print \"the third thing (f) If A = 4 then if B

Solution

1.when the memory alloted will exhaust,at that that the while loop will stop.because it cannot hold more numbers due to memory deficit

2.a) the first string //the condition is true because a is more than b

b) will not compile//error because = means assignment and it is not used inside if..equal to should be ==

c) the first thing //value of c is more than d.so cndition is true

d)the first thing //the condition is true.c is smaller than d

e)the second thing //c is smaller than b

f) the first thing //b is less than c

3) error because jth loop is not mentioned or given and it is tried to increment.for program to work it should be i which must be incremented

4)if i=i+2 is used after the print statement, then message will be printed 5 times

5) 5 4 3 2 1. //because value of j will print and decrement from 5 to 0.

6)

7)

Control Structures and Subroutines I. A while loop whose condition is not made false is called an infi nite loop. However, it is infinite, in the sense of conti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site