True or False? and explain why. C language

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education