True or False? and explain why. C language

Microsoft Visual C#
7th Edition
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Joyce, Farrell.
Chapter7: Using Methods
Section: Chapter Questions
Problem 20RQ
icon
Related questions
Question

True or False? and explain why.

C language

Code fragment 1:
int i=0;
int scores[]={0,0,0};
while(i<3)
{
printf("Scores: ");
scanf("%d", &scores[i]);
i++;
}
if((scores[0]<=scores[1])&&(scores[1]!=scores[2]))
{
scores[0]+=3;
printf("score 1: %d\n",scores[0]);
}
else if(!(scores[0]==20))
{
scores[1]-=2;
scores[i-2]=100;
for(i=0;i<30;i++)
{
printf("%d %d\n",scores[0], scores[1]);
}
}
else
{
printf("CTG currently doing DOTD on The Breakfast Club....\n");
}
Transcribed Image Text:Code fragment 1: int i=0; int scores[]={0,0,0}; while(i<3) { printf("Scores: "); scanf("%d", &scores[i]); i++; } if((scores[0]<=scores[1])&&(scores[1]!=scores[2])) { scores[0]+=3; printf("score 1: %d\n",scores[0]); } else if(!(scores[0]==20)) { scores[1]-=2; scores[i-2]=100; for(i=0;i<30;i++) { printf("%d %d\n",scores[0], scores[1]); } } else { printf("CTG currently doing DOTD on The Breakfast Club....\n"); }
True or False:
11. If the value held at index 0 in the scores array is equal to the index of the array, we can say for certain
that the first if statement will execute.
12. We cannot say for sure what the value of i will be right after the while loop is done executing.
13. The else-if block will only execute if the value in index 0 equals 20.
14. scores[1]=printf("hello!"); would be a valid line of code.
15. In the else-if block, scores[i-2]=100; will always be updating the same index.
16. CTG currently doing DOTD on The Breakfast Club.... would be output to screen if the user enters the
numbers at the prompt in the while loop: 20, 7 and 6 (in that order)
17. We cannot say for sure how many times the for loop will execute if it starts.
18. If the for loop executes, we can say for sure what the value of the third argument in the print statement
(in the for loop) will be.
Transcribed Image Text:True or False: 11. If the value held at index 0 in the scores array is equal to the index of the array, we can say for certain that the first if statement will execute. 12. We cannot say for sure what the value of i will be right after the while loop is done executing. 13. The else-if block will only execute if the value in index 0 equals 20. 14. scores[1]=printf("hello!"); would be a valid line of code. 15. In the else-if block, scores[i-2]=100; will always be updating the same index. 16. CTG currently doing DOTD on The Breakfast Club.... would be output to screen if the user enters the numbers at the prompt in the while loop: 20, 7 and 6 (in that order) 17. We cannot say for sure how many times the for loop will execute if it starts. 18. If the for loop executes, we can say for sure what the value of the third argument in the print statement (in the for loop) will be.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Structured English
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage