Is the following statement legal? for int y-y-o) a. yes 9. b. no Answer: 10. The
ID: 3903351 • Letter: I
Question
Is the following statement legal? for int y-y-o) a. yes 9. b. no Answer: 10. The general form of the while loop is: a. while(condition) statement; b. while(initialization) statement; c. while(iteration) statement: Answer: 11. For a while loop, the body could be executed (depending on the co ndit a. at least once; b. at least twice; c. from 0 to n times; Answer: 12. For a while loop to terminate, the loop control variable is usually loop body. a. true b. false Answer 13. The general form of the do-while loop is: a. do (statements;3 while(condition); b. do (condition) (statements;3 while; c. do {condition;) while(statements); nswerExplanation / Answer
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
9.Is the following statement legal?
for(int y=0;y=0;)
Answer : b.no
Explanation : Following is the syntax
Syntax : for(initilization;condition;increment/decrement) { statements; }
Example : int i;
for(i=0;i<=10;i++) {}
Here in given for loop initilization is given ib two times. Also declaration of variable is not allowed in for loop, hence the answer is no.
10. The general form of the whle loop is :
Answer : a. while(condition) statement;
Explanation : Following is syntax for while loop
Syntax : while(condition) { statements; }
Example : int i=0; // declaring variable i and initializing it to 0
while ( i < 5) { // while loop condition
printf("%d",i); // printing value of i
i++; //incrementing value of i
}
Hence the answer is a.
11.For a while loop , the body could be executed (depending on the condition)
Answer : c.from 0 to n times;
Explanation : While loop executes the target statements untill and unless condition is true. hence as condition become false in the first throw the statement will be skipped. hence the answer c.from 0 to n times.
12. For a while loop to terminate , the loop control variable is usually in loop body
Answer : True
Explanation : In while loop control variable is declared in loop body
Example : int i=0; // declaring variable i and initializing it to 0
while ( i < 5) { // while loop condition
printf("%d",i); // printing value of i
i++; //incrementing value of i ,
}
13. The general form of the do-while loop is :
Answer : a. do {statements;} while(condition);
Explanation : Following is syntax for do-while
Syntax : do {statements;} while(condition);
Example : int i=0;
do {
printf("%d", i); // printing value of i;
}while(i<2); // condition
hence the answer.
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.