Respuesta :
Answer:
1.
Problem 1: I am using IF ELSE in this pseudo code
PSEUDOCODE1
initialize a to 1
b = a+1
c = a + b
If c is less than 5
start from the beginning (and increment a)
else
stop the program
This can be better done using simple english words
PSEUDOCODE2
Steps Statement
01 initialize a to 1
02 assign value of a+1 to b
03 assign the sum of a and b to c
04 If c is less than 5
05 go to the beginning
06 increment a in 01
07 repeat 02 and 03
08 repeat steps 06 02 and 03 Until c<5
09 else stop
Flowchart
It is given in the attached file flowchart
Problem 2
In the question the condition increment 'c' by 1 seems to be a typo. and it should be 'a' by 1. If we increment c by 1 each loop, it does nothing because c is will be set again by the calculation of c = a + b.
IF the condition is increment c by 1 then the answer is that no amount of loops will have c meet the condition as it resets each loop.
For the condition increment a by 1 the answer is that it will take two loops. First loop c has 3 and in the second loop if it is according to incrementing by 1, c is 5. When c is 5 this means that the condition c<5 becomes false as c gets equal to 5. So the program will end after this i.e after 2nd loop.
Lets understand this
- At first a=1, b=a+1=1+1=2, so b=2, c=a+b so c=1+2 c=3
- At second a is incremented by 1, so it becomes a=2, b=a+1 so b=2+1 so b=3, c=a+b which means c=2+3 so c=5
- Program ends after two loops as the condition has been met.
Above pseudo code can be modified for 2 as
PSEUDOCODE1
initialize a to 1
b = a+1
c = a + b
If c is less than 5
start from the beginning (and increment a)
else
stop the program
print a
Flowchart 2 is attached
For the condition incrementing c by 1
PSEUDOCODE
a=1
b=a+1
c=a+b
while c is less than 5:
increment c by 1
END while
display c
Flowchart 3 is attached
Number of loops here will be 5. This is explained below:
- first iteration: a=1, b=2, c=3
- c<5 so c is incremented by 1. This means c becomes 4 (c=3+1)
- condition c<5 is again true, so c is incremented by 1 again, This means value of c becomes 5 (c=4+1).
- The loop breaks as the condition c<5 gets false because now the value of c=5. This value is displayed.
- So 5 loops will be necessary to meet this condition.