QUESTION 4 Which of the following for statements would be executed the same numb
ID: 3700511 • Letter: Q
Question
QUESTION 4
Which of the following for statements would be executed the same number of times as the following while statement?
int num = 10;
while(num > 0)
{
WriteLine(num);
num--;
}
for (num = 1; num < 10; num++)
for (num = 0; num < 10; num++)
for (num = 100; num == 10; num += 10)
for (num = 10; num < 0; num--);
none of the above
QUESTION 5
Given the following statement, __________ would be the output produced
for (int cnt = 0; cnt < 3; cnt++)
Write(cnt);
QUESTION 6
Loops are needed in programming languages:
to facilitate sequential processing of data
to enable a variable to be analyzed for additional processing
to allow statements to be repeated
to process files stored on hard drives
all of the above
for (num = 1; num < 10; num++)
for (num = 0; num < 10; num++)
for (num = 100; num == 10; num += 10)
for (num = 10; num < 0; num--);
none of the above
QUESTION 5
Given the following statement, __________ would be the output produced
for (int cnt = 0; cnt < 3; cnt++)
Write(cnt);
QUESTION 6
Loops are needed in programming languages:
to facilitate sequential processing of data
to enable a variable to be analyzed for additional processing
to allow statements to be repeated
to process files stored on hard drives
all of the above
Explanation / Answer
1)
int num = 10;
while(num > 0)
{
WriteLine(num);
num--;
}
Answer:
for (num = 0; num < 10; num++) would be executed the same number of times as the following while statement.
Reason:
--------
beause for (num = 1; num < 10; num++) , starts executing with 1,
for (num = 100; num == 10; num += 10),
for (num = 10; num < 0; num--); doesnot executed the same number of times as the following while statement.
2)Given the following statement, __________ would be the output produced
for (int cnt = 0; cnt < 3; cnt++)
Write(cnt);
Answer:)
to facilitate sequential processing of data.
Thanks Have a great day.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.