Unit 1 - Practice Quiz

CSE101 50 Questions
0 Correct 0 Wrong 50 Left
0/50

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

A. _variableName
B. variable_123
C. 1stVariable
D. variableName

2 Which of the following is a Keyword in C?

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

3 What is the size of the char data type in C?

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

4 Which format specifier is used for a floating-point number?

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

5 Identify the correct way to declare a constant in C.

A. int constant x = 10;
B. const int x = 10;
C. constant int x = 10;
D. x = 10 const;

6 What is the result of the expression in C?

A. 2.5
B. 2
C. 1
D. 0

7 Which of the following is the correct order of precedence (highest to lowest) for arithmetic operators?

A. +, -, *, /, %
B. *, /, %, +, -
C. +, -, %, *, /
D. %, +, -, *, /

8 What is the output of the following expression: 3 + 4 * 5?

A. 35
B. 23
C. 12
D. 60

9 Which operator is used to increment the value of a variable by 1?

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

10 If x = 5, what is the value of y after y = x++?

A. 5
B. 6
C. 4
D. Undefined

11 If x = 5, what is the value of y after y = ++x?

A. 5
B. 6
C. 4
D. Undefined

12 Which of the following is a Relational Operator?

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

13 What is the return type of a relational expression like (a > b)?

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

14 What is the result of 10 && 5?

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

15 What is the result of 0 || 5?

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

16 Which operator performs a bitwise AND?

A. &&
B. &
C. |
D. ^

17 What is the result of 5 & 3? (Assume 5 is 0101 and 3 is 0011 in binary)

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

18 What does the expression x << 2 do to the integer x?

A. Divides x by 2
B. Multiplies x by 2
C. Divides x by 4
D. Multiplies x by 4

19 Which operator is the Ternary Operator?

A. ?:
B. if-else
C. ::
D. ->

20 Evaluate: (10 > 5) ? 100 : 200

A. 100
B. 200
C. 10
D. 5

21 What is the purpose of the sizeof operator?

A. To calculate the length of a string
B. To return the memory address of a variable
C. To return the size of a variable or type in bytes
D. To calculate the magnitude of a number

22 Which assignment operator is equivalent to a = a + b?

A. a =+ b
B. a += b
C. a ++ b
D. a + b = a

23 Which of the following creates a hexadecimal integer constant?

A. 0x1A
B. 01A
C. 1A
D. #1A

24 Which is the correct range for a signed char (assuming 1 byte)?

A. 0 to 255
B. -128 to 127
C. -32768 to 32767
D. 0 to 65535

25 What is the associativity of the assignment operator =?

A. Left to Right
B. Right to Left
C. Random
D. None

26 Which of the following is NOT a valid string constant?

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

27 What is the output of 5 / 2 in C (integer arithmetic)?

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

28 Which operator converts the bits of a number to their opposite (0 becomes 1, 1 becomes 0)?

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

29 What happens if you try to use the modulus operator % with floating-point numbers?

A. It returns the remainder
B. It returns the quotient
C. Compile-time error
D. It rounds the result

30 What is the value of x after: int x = 10; x = (x == 10);?

A. 10
B. 1
C. 0
D. True

31 Which is the Bitwise XOR operator?

A. |
B. &
C. ^
D. #

32 What is the result of 10 ^ 10?

A. 10
B. 20
C. 100
D. 0

33 Which of the following variables uses the PascalCase naming convention (though not enforced by C)?

A. myVariable
B. MyVariable
C. my_variable
D. MY_VARIABLE

34 Implicit type conversion is also known as:

A. Type Casting
B. Type Promotion
C. Type Def
D. Type Struct

35 What is the result of !0?

A. 0
B. 1
C. -1
D. NULL

36 In the expression a = 5, b = 10, c = 15;, which operator is used?

A. Separator operator
B. Comma operator
C. Sequence operator
D. List operator

37 Which of the following is a valid octal constant?

A. 075
B. 085
C. 75
D. 0x75

38 Which logical operator has the highest precedence?

A. &&
B. ||
C. !
D. They are equal

39 If int a = 10;, what is the value of a after a *= 2 + 3;?

A. 23
B. 50
C. 13
D. 20

40 Which header file is typically included to use printf?

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

41 What is the result of 1 < 2 < 3 in C?

A. 0
B. 1
C. Error
D. True (Boolean type)

42 What is the result of 3 < 2 < 1 in C?

A. 0
B. 1
C. Error
D. False

43 Which of these characters represents the null terminator in a string?

A. \n
B. \0
C. \t
D. 0

44 Short-circuit evaluation means:

A. The program stops if there is a short circuit
B. The second operand of && or || is not evaluated if the result is determined by the first
C. Variables are initialized to zero
D. Code runs faster by skipping loops

45 Which is the correct way to write as a floating point constant?

A. 2*10^3
B. 2e3
C. 2E-3
D. 2000

46 What is the value of ~0 (assuming 2's complement arithmetic)?

A. 0
B. 1
C. -1
D. Maximum Integer

47 Which operator is used to get the address of a variable?

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

48 What is the precision of a double relative to a float?

A. Lower
B. Same
C. Higher
D. Undefined

49 Can keywords be used as variable names if written in uppercase?

A. No, never
B. Yes, because C is case-sensitive
C. Only in special functions
D. Yes, but it is bad practice

50 Which operator forces a specific type conversion manually?

A. The cast operator (type)
B. The convert operator
C. The change function
D. The assignment operator