Unit 1 - Practice Quiz

CSE109

1 Which of the following is NOT a valid variable name definition in C?

A. int _a3;
B. int 3a;
C. int a_3;
D. int a3;

2 Which standard library header is typically included to use the printf and scanf functions?

A. <conio.h>
B. <stdlib.h>
C. <stdio.h>
D. <math.h>

3 What is the result of the expression in C when both operands are integers?

A. $2.5$
B. $2.0$
C. $2$
D. $3$

4 Which of the following is a valid keyword in C?

A. integer
B. volatile
C. main
D. constant

5 What is the size of a char data type in C?

A. 2 bytes
B. 1 byte
C. 4 bytes
D. 8 bytes

6 Which operator is used to calculate the remainder of an integer division?

A.
B.
C.
D.

7 What is the correct format specifier for a double-precision floating-point variable?

A. %d
B. %f
C. %lf
D. %c

8 Which of the following represents a hexadecimal constant in C?

A. 012
B. 0x12
C. 12h
D. 12x

9 Identify the ternary (conditional) operator.

A. if-else
B. ?:
C. ||
D. ==

10 What is the result of the bitwise AND operation: ?

A. $0$
B. $1$
C. $7$
D. $5$

11 Which of the following is an invalid string constant?

A. "Hello"
B. "123"
C. 'Hello'
D. ""

12 What is the associativity of the assignment operator (=)?

A. Left to Right
B. Right to Left
C. Random
D. Center Out

13 Which of the following is a Relational Operator?

A. &&
B. =
C. >=
D. <<

14 What happens if you assign a float value $3.14$ to an int variable?

A. The compiler throws an error.
B. The value is rounded to the nearest integer ($3$).
C. The value is truncated to the integer part ($3$).
D. The value becomes garbage.

15 Which operator has the highest precedence?

A. (Addition)
B. (Assignment)
C. (Equality)
D. (Multiplication)

16 What is the value of x after the following code executes?
int x = 5;
x += 10;

A. $5$
B. $10$
C. $15$
D. $510$

17 The logical NOT operator is represented by:

A. ~
B. !
C. !=
D. ^

18 Which escape sequence represents a newline?

A. \t
B. \n
C. \r
D. \a

19 Which data type would be best suited to store the value True or False in C99?

A. int
B. char
C. _Bool
D. float

20 What is the output of sizeof(double) on a standard 32-bit or 64-bit system?

A. 2
B. 4
C. 8
D. 10

21 Which of the following creates an octal constant?

A. Prefixing with o
B. Prefixing with 0 (zero)
C. Suffixing with 8
D. Prefixing with #

22 Evaluate: 10 && 0

A. $10$
B. $0$ (False)
C. $1$ (True)
D. Error

23 What does the increment operator ++ do?

A. Adds 2 to the variable
B. Adds 1 to the variable
C. Doubles the variable
D. Returns the address of the variable

24 Consider int a = 10; int b = a++;. What are the values of a and b?

A.
B.
C.
D.

25 Which operator is used to perform a Left Shift?

A. >>
B. <<
C. <
D. <<<

26 What is the range of a signed char?

A. $0$ to $255$
B. to $127$
C. to $32767$
D. $0$ to $65535$

27 Which of the following is NOT a C unary operator?

A. ++
B. sizeof
C. & (Address of)
D. %

28 The expression a = (b = 5, b + 2) results in a having the value:

A. $5$
B. $7$
C. $2$
D. Syntax Error

29 What is the result of 1 ^ 1 in C?

A. $0$
B. $1$
C. $2$
D. $11$

30 How are comments written in C (single line)?

A. # comment
B. <!-- comment -->
C. // comment
D. /* comment

31 Which header file is required to use INT_MAX?

A. <stdio.h>
B. <limits.h>
C. <conio.h>
D. <stdlib.h>

32 In the expression if (a > b && c > d), if a > b is false, what happens?

A. c > d is evaluated next.
B. c > d is NOT evaluated.
C. The program crashes.
D. The compiler generates an error.

33 The sizeof operator returns the size in:

A. Bits
B. Bytes
C. Words
D. Kilobytes

34 What is the decimal equivalent of the bitwise left shift 3 << 2?

A. $6$
B. $12$
C. $9$
D. $32$

35 Which of these identifiers follows the 'CamelCase' convention (often used, though snake_case is common in C)?

A. student_grade
B. StudentGrade
C. studentgrade
D. STUDENT_GRADE

36 Which operator performs a one's complement (inverts all bits)?

A. !
B. -
C. ~
D. ^

37 What is the correct syntax to declare a constant variable PI with value $3.14$?

A. constant float PI = 3.14;
B. const float PI = 3.14;
C. float const = 3.14 PI;
D. var const PI = 3.14;

38 What is the value of x? int x = 4 + 2 * 3;

A. $18$
B. $10$
C. $9$
D. $24$

39 Which character represents the null terminator in a C string?

A. '0'
B. '\0'
C. '\n'
D. NULL

40 If x = 5, what is x += x + x?

A. $10$
B. $15$
C. $25$
D. $20$

41 Which of these is a valid scientific notation constant in C?

A. 2.3e-2
B. 2.3 x 10^-2
C. 2.3^-2
D. e2.3

42 The result of a relational operator (e.g., a < b) is always:

A. The smaller value
B. The larger value
C. $0$ or $1$
D. true or false keyword

43 What is the l-value in the statement a = 10;?

A. 10
B. a
C. =
D. ;

44 Which variable declaration would allow storage of the largest integer value?

A. int
B. unsigned int
C. short
D. unsigned long long

45 Evaluate the condition: !5

A. $5$
B.
C. $0$
D. $1$

46 What is the associativity of the Logical OR operator ||?

A. Right to Left
B. Left to Right
C. Top to Bottom
D. None

47 What is the output of printf("%d", 'A'); assuming ASCII encoding?

A. A
B. 65
C. 97
D. Error

48 Bitwise operators can operate on which type of variables?

A. float and double
B. int and char
C. void
D. All data types

49 Which of the following is NOT a C token?

A. Keyword
B. Identifier
C. Operator
D. Comment

50 What is the result of 10 % 3?

A. $3.33$
B. $3$
C. $1$
D. $0$