Unit 1 - Practice Quiz

CSE101

1 Which of the following is NOT a valid identifier in C?

A. _myVar
B. my_Var
C. 1stVar
D. Var1

2 Which of the following is a reserved keyword in C?

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

3 What is the memory size typically allocated for a char data type in C?

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

4 Which escape sequence is used to represent a newline character?

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

5 What is the correct format specifier to print a double variable?

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

6 How is a hexadecimal constant represented in C?

A. Prefix 0x
B. Prefix 0
C. Suffix H
D. Prefix #

7 What is the result of the expression in C?

A. 2
B. 2.5
C. 1
D.

8 Which of the following operators has the highest precedence?

A. +
B. ==
C. *
D. =

9 What is the output of the following code snippet?
int a = 10; printf("%d", a++);

A. 10
B. 11
C. 12
D. Compilation Error

10 The expression a = 5 returns which value?

A. True
B. 1
C. 5
D.

11 Which of the following is a valid string constant?

A. 'Hello'
B. "Hello"
C. {Hello}
D. [Hello]

12 What is the range of a signed int if it occupies 2 bytes?

A. 0 to 65535
B. to
C. to
D. to

13 Which operator is used to determine the size of a data type or variable in bytes?

A. length()
B. size()
C. sizeof
D. malloc

14 What is the result of 3 << 2?

A. 6
B. 12
C. 9
D. 5

15 The Bitwise AND operator is represented by:

A. &&
B. &
C. |
D. !

16 What is the output of int x = 5.9; printf("%d", x);?

A. 5.9
B. 6
C. 5
D. Runtime Error

17 Which of the following is a ternary operator?

A. if-else
B. ?:
C. switch
D. &&

18 If a = 10 and b = 20, what is the result of (a > b) && (b++)?

A. 1
B.
C. True
D. Compilation Error

19 Which header file is required for printf and scanf?

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

20 What is the result of ~0 (Bitwise NOT of 0) on a standard system using 2's complement?

A.
B. 1
C. -1
D. All bits set to 0

21 Which variable declaration is invalid?

A. int _count;
B. float rate2;
C. double break;
D. char c;

22 What logic does the Bitwise XOR (^) operator follow?

A. Returns 1 if both bits are 1
B. Returns 1 if both bits are 0
C. Returns 1 if bits are different
D. Returns 1 if bits are same

23 The associativity of the assignment operator (=) is:

A. Left to Right
B. Right to Left
C. Random
D. Compiler Dependent

24 What is the value of x after: int x = 4 + 2 * 3;?

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

25 Which of the following is NOT a derived data type?

A. Array
B. Pointer
C. Function
D. int

26 What defines a constant variable in C?

A. static
B. volatile
C. const
D. fixed

27 What is the output of 5 | 2?

A. 7
B. 3
C. 5
D. 2

28 What happens if you use the modulus operator % on float variables?

A. Returns integer remainder
B. Returns float remainder
C. Compilation Error
D. Rounds to nearest int

29 Which of the following correctly represents logical OR?

A. &
B. ||
C. |
D. or

30 What is the result of !5?

A. 5
B. -5
C. 1
D.

31 In the expression c = a > b ? a : b;, what does c store?

A. Always a
B. Always b
C. The larger of a and b
D. The smaller of a and b

32 Which operator is used to access the address of a variable?

A. *
B. &
C. ->
D. @

33 What is the value of x? int x = (1, 2, 3);

A. 1
B. 2
C. 3
D. Compilation Error

34 Which format specifier is used for a string?

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

35 What is the result of right shifting (-1 >> 1) generally on signed integers?

A.
B. 1
C. -1
D. MAX_INT

36 Which of the following is an l-value?

A. 10
B. x + y
C. var
D. a++

37 What is the implicit type conversion hierarchy (Arithmetic conversion) from low to high?

A. int -> char -> float -> double
B. char -> int -> float -> double
C. float -> double -> int -> char
D. double -> float -> int -> char

38 Which of the following is correct regarding variable names?

A. They are case-insensitive
B. They can contain spaces
C. They can be of any length (compiler specific)
D. They can start with a number

39 What is the output of int x = 10; x += x *= 2; printf("%d", x);?

A. 20
B. 30
C. 40
D. 10

40 Which logical operator has the highest precedence?

A. &&
B. ||
C. !
D. ==

41 What is the binary representation of 10?

A. 1010
B. 1001
C. 1100
D. 0101

42 Which of the following is a Unary operator?

A. *
B. ++
C. %
D. ^

43 What does the expression (float)9/2 evaluate to?

A. 4
B. 4.0
C. 4.5
D. 4.500000

44 Which of the following is NOT a fundamental data type in C?

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

45 What is the value of z? int x=5, y=10; int z = (x < y) ? x++ : y++;

A. 5
B. 6
C. 10
D. 11

46 A variable declared inside a function without a storage class is implicitly:

A. extern
B. static
C. auto
D. global

47 Which statement about comments in C is true?

A. // starts a multi-line comment
B. /* and */ are for single line only
C. Nested comments /* ... /* ... */ ... */ are allowed
D. /* ... */ handles multi-line comments

48 What is the ASCII value of character '0' (zero)?

A.
B. 48
C. 65
D. 97

49 What is the result of 1 ^ 1?

A. 1
B.
C. 2
D. True

50 Which operator performs a 'One's Complement'?

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