Computer Science, asked by mahakasati26, 3 months ago

WHILE C <=50
PRINT C
C=C +
WEND
6. The following program is supposed to display 20, 18, 16, 14, 12 ... 2 what should be the
value of STEP in the program.
FOR I = 20 TO 2 STEP
PRINTI
NEXTI
7. Convert the program written using DO WHILE-LOOP to FOR-NEXT loop.
J = 7
DO WHILE I <= 49
PRINTI
I=I +7
LOOP
END​

Answers

Answered by PYSCHOO
1

Answer:

If the condition is found true, then statements written in the body of the while loop i.e., inside the braces { } are executed. Then, again the condition is checked, and if found true then statements in the body of the while loop are executed again. This process continues until the condition becomes false.

For better understanding, let's understand our example step by step.

In our example, firstly, we assigned a value of 1 to a variable 'a'.

while(a <= 10) checks the condition 'a <= 10'. Since the value of a is 1 which is less than 10, the statements of while (within the braces { }) are executed.

'Hello World' is printed and a++ increases the value of 'a' by 1. So, now the value of 'a' becomes 2.

Now, again the condition is checked. This time also a <= 10 is true because the value of 'a' is 2. So, again 'Hello World' is printed and the value of 'a' increased to 3.

When the value of 'a' becomes 10, again the condition a <= 10 is true and 'Hello World' is printed for the tenth time. Now, a++ increases the value of 'a' to 11.

This time, the condition a <= 10 becomes false and the while loop terminates.

Explanation:

Similar questions