Logic operators quiz, While loop questions & Switch questions (C for Everyone: Programming Fundamentals - Week 3 Coursera)

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

#include <stdio.h> #include <stdlib.h> int main(void) { int a = 0, b = 1, c = 2; If (a < b) printf (" TRUE\n"); else printf(" FALSE\n"); If (a < b - c) printf (" TRUE\n"); else printf(" FALSE\n"); If (b < c - 1) printf (" TRUE\n"); else printf(" FALSE\n"); If (!c) printf (" TRUE\n"); else printf(" FALSE\n"); return 0; } What does the program print as a first line?

True

while (i < 5){ i = i - 1; printf(" i = %d", i); } If i starts off as 2 (assume int i = 2 declared at the beginning of the code) then...

printf will print continuously

while (i < 5){ i = i - 1; printf(" i = %d", i); } If i starts off as 15 (assume int i = 15 declared at the beginning of the code), printf will print ...

will not print

If i starts out as 2 the printf will print

case 2 case 3

while (i < 5){ i = i - 1; printf(" i = %d", i); } If i starts off as 2 (assume int i = 2 declared at the beginning of the code) and the loop statement was i = i +1; printf will print ...

i = 3 i = 4 i = 5

#include <stdio.h> #include <stdlib.h> int main(void) { int a = 0, b = 1, c = 2; If (a < b) printf (" TRUE\n"); else printf(" FALSE\n"); If (a < b - c) printf (" TRUE\n"); else printf(" FALSE\n"); If (b < c - 1) printf (" TRUE\n"); else printf(" FALSE\n"); If (!c) printf (" TRUE\n"); else printf(" FALSE\n"); return 0; } What does the program print as a fourth line?

F

#include <stdio.h> #include <stdlib.h> int main(void) { int a = 0, b = 1, c = 2; If (a < b) printf (" TRUE\n"); else printf(" FALSE\n"); If (a < b - c) printf (" TRUE\n"); else printf(" FALSE\n"); If (b < c - 1) printf (" TRUE\n"); else printf(" FALSE\n"); If (!c) printf (" TRUE\n"); else printf(" FALSE\n"); return 0; } What does the program print as a second line?

F

#include <stdio.h> #include <stdlib.h> int main(void) { int a = 0, b = 1, c = 2; If (a < b) printf (" TRUE\n"); else printf(" FALSE\n"); If (a < b - c) printf (" TRUE\n"); else printf(" FALSE\n"); If (b < c - 1) printf (" TRUE\n"); else printf(" FALSE\n"); If (!c) printf (" TRUE\n"); else printf(" FALSE\n"); return 0; } What does the program print as a third line?

F

switch(i){ case 1: printf("case 1 \n"); break; case 2: printf("case 2 \n"); case 3: printf("case 3 \n");break; default: printf("default case \n"); }; Use the code above for all of the questions. If i starts off as 1 then printf will print

case 1

If i starts out as 15 the printf will print

default case


संबंधित स्टडी सेट्स

Algebra (DIVIDING BY A MONOMIAL)

View Set

Deeds - Requirements for VALID conveyance

View Set

Module 00102-15 Exam Introduction to Construction Math

View Set

COMBINED FLASH CARDS FOR RI BOATING EXAM; 1. ri boating license test TR edits; 2. BOAT Licensing Exam Terms use this one separate questions from website

View Set

Examen parcial oral Span 152: Preguntas de prática

View Set

Successions: Inheritance Rights in general

View Set

Issues In Global Business Misterm

View Set