Quiz #1 (Up to Lecture 04, Chap 4) - Programming Quiz - eClass PDF
Document Details
Uploaded by Deleted User
2024
Tags
Summary
This document contains a programming quiz in C, assessing understanding of concepts up to Lecture 04 and Chapter 4. The quiz comprises multiple-choice questions. It tests knowledge of variables, operators, and functions in the C programming language.
Full Transcript
Started on Thursday, 19 September 2024, 9:14 PM State Finished Completed on Thursday, 19 September 2024, 9:19 PM Time taken 4 mins 18 secs Question 1 Complete Marked out of 1.00 What is the value of b after executing the following lines? int a, b; a = 3...
Started on Thursday, 19 September 2024, 9:14 PM State Finished Completed on Thursday, 19 September 2024, 9:19 PM Time taken 4 mins 18 secs Question 1 Complete Marked out of 1.00 What is the value of b after executing the following lines? int a, b; a = 3; b = a++ * 2 + 2; Select one: None of them cross out 10 cross out 8 cross out 4 cross out Question 2 Complete Marked out of 1.00 What is the value of i after the following lines? int i = 1, j = 2; i * j + 3; Select one: The value of i will not be set in these lines. cross out The line contains a syntax error. cross out -1 cross out 1 cross out 0 cross out Question 3 Complete Marked out of 1.00 Which of the variables will be read in values from the user input string 10 , 3.14,5? int a, c; float b; scanf(“%d,%f,%d”, &a, &b, &c); Select one: a. None of them cross out b. a and c cross out c. a and b cross out d. Only a cross out e. a, b, and c cross out Question 4 Complete Marked out of 1.00 What is the output? int x = 007; printf("%3d”, x); Select one: a. __7 (each of the two underscores indicates a space) cross out b. None of the above cross out c. 7 cross out d. 007 cross out e. 7__ (each of the two underscores indicates a space) cross out Question 5 Complete Marked out of 1.00 True or False: In this course, it's okay to discuss the lab exercises with other students. Select one: True False Question 6 Complete Marked out of 1.00 Is the value of the expression(a++) equivalent to the value of the expression (a += 1)? Select one: True False Question 7 Complete Marked out of 1.00 What is the executable file named if we compile using the following line? gcc celsius.c Select one: a.out cross out Celsius cross out celsius cross out celsius.c cross out Question 8 Complete Marked out of 1.00 What is the value of i after the following lines? int i = 2, j = 1, k = 1; i = j += k = 3; Select one: 4 cross out 6 cross out The line contains a syntax error. cross out The value of i will not be set in these lines. cross out 5 cross out Question 9 Complete Marked out of 1.00 Which of the following can be used as valid identifiers in C? There may be multiple correct answers. Select all that apply: a. float cross out b. _float_ cross out c. float2 cross out d. float-2 cross out e. 2float cross out f. Float cross out Question 10 Complete Marked out of 1.00 What is the output? int x = 314; printf("%+06d”, x); Select one: a. +00314 cross out b. __+314 (each of the three underscores indicates a space) cross out c. 00+314 cross out d. 314 cross out e. None cross out Question 11 Complete Marked out of 1.00 What is the output? float x = 5.9999; printf(“%.2f”, x); Select one: a. 5 cross out b. 5.9 cross out c. 6 cross out d. 6.00 cross out e. 5.99 cross out Question 12 Complete Marked out of 1.00 Which of the variables will be read in values from the user input string 9.27,10,5.3? int a, b; float c; scanf(“%d%f%d”, &a, &b, &c); Select one: a. Only a cross out b. None of them cross out c. a and b cross out d. a and c cross out e. a,b and c cross out Question 13 Complete Marked out of 1.00 True or False: The following pair of scanf format strings is equivalent. "%d" and " %d" Select one: True False Question 14 Complete Marked out of 1.00 What is the output if the user input is 3.14159265? float x; scanf(“%d”, &x); printf(“%.2f”, x); Select one: a. 3.141593 cross out b. 3.00 cross out c. None of the above cross out d. 3.000000 cross out e. 3.14 cross out Question 15 Complete Marked out of 1.00 Which of the following flags are required for compilation in this course? Select all that apply: -Werror cross out -ansi cross out -std=c89 cross out -std=c99 cross out -Wall cross out -w cross out -pedantic cross out