Unit 1 - Practice Quiz

CSE109 50 Questions
0 Correct 0 Wrong 50 Left
0/50

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

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

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

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

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

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

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

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

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

A. 1 byte
B. 4 bytes
C. 8 bytes
D. 2 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. %c
B. %d
C. %f
D. %lf

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

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

9 Identify the ternary (conditional) operator.

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

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

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

11 Which of the following is an invalid string constant?

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

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

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

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 value is rounded to the nearest integer ($3$).
B. The value is truncated to the integer part ($3$).
C. The compiler throws an error.
D. The value becomes garbage.

15 Which operator has the highest precedence?

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

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

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

17 The logical NOT operator is represented by:

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

18 Which escape sequence represents a newline?

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

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

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

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

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

21 Which of the following creates an octal constant?

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

22 Evaluate: 10 && 0

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

23 What does the increment operator ++ do?

A. Adds 1 to the variable
B. Adds 2 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. to $32767$
B. $0$ to $255$
C. to $127$
D. $0$ to $65535$

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

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

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

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

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

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

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. <limits.h>
B. <stdio.h>
C. <conio.h>
D. <stdlib.h>

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

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

33 The sizeof operator returns the size in:

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

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

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

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

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

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. var const PI = 3.14;
C. float const = 3.14 PI;
D. const float PI = 3.14;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

45 Evaluate the condition: !5

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

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

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

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

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

48 Bitwise operators can operate on which type of variables?

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

49 Which of the following is NOT a C token?

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

50 What is the result of 10 % 3?

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