Find errors, if any, in the following FOR statements.
1. FOR B = 1, 20
2.FOR K = 1 to 10 STEP -2
3.FOR P = -1 to 1 STEP 0.05
4.FOR Y = 10 to 2 STEP 2
5.FOR Y 1 = 10 to 10 STEP 0.1
Answers
Answered by
0
Answer:
i don't know, please give me a crt answer immediately
Answered by
0
Answer:
Concept:
A convenient method for iterating across a range of values is the for statement. Because it loops repeatedly until a specific condition is met, programmers frequently refer to it as the "for loop."
Explanation:
- General syntax for declaring/defining for statement is:
for (initialization; termination; increment)
{
statement(s)
}
- FOR B = 1, 20
No step increment/decrement value.
- FOR K = 1 to 10 STEP -2
As given step count is -2 and the initialized value from 1 to 10, the loop is wrong.
- FOR P = -1 to 1 STEP 0.05
No error
- FOR Y = 10 to 2 STEP 2
As given step count is 2 and the initialized value from 10 to 2, the loop is wrong.
- FOR Y 1 = 10 to 10 STEP 0.1
Both initialized value and terminating value are same.
#SPJ2
Similar questions