Unit 1 - Practice Quiz
1 Which of the following is NOT a valid identifier in C?
_variableName
variable_123
1stVariable
variableName
2 Which of the following is a Keyword in C?
integer
volatile
constant
main
3
What is the size of the char data type in C?
4 Which format specifier is used for a floating-point number?
%d
%c
%f
%s
5 Identify the correct way to declare a constant in C.
int constant x = 10;
const int x = 10;
constant int x = 10;
x = 10 const;
6 What is the result of the expression in C?
7 Which of the following is the correct order of precedence (highest to lowest) for arithmetic operators?
+, -, *, /, %
*, /, %, +, -
+, -, %, *, /
%, +, -, *, /
8
What is the output of the following expression: 3 + 4 * 5?
9 Which operator is used to increment the value of a variable by 1?
**
--
++
%%
10
If x = 5, what is the value of y after y = x++?
11
If x = 5, what is the value of y after y = ++x?
12 Which of the following is a Relational Operator?
=
==
&&
<<
13
What is the return type of a relational expression like (a > b)?
bool
char
int
float
14
What is the result of 10 && 5?
15
What is the result of 0 || 5?
16 Which operator performs a bitwise AND?
&&
&
|
^
17
What is the result of 5 & 3? (Assume 5 is 0101 and 3 is 0011 in binary)
18
What does the expression x << 2 do to the integer x?
x by 2
x by 2
x by 4
x by 4
19 Which operator is the Ternary Operator?
?:
if-else
::
->
20
Evaluate: (10 > 5) ? 100 : 200
21
What is the purpose of the sizeof operator?
22
Which assignment operator is equivalent to a = a + b?
a =+ b
a += b
a ++ b
a + b = a
23 Which of the following creates a hexadecimal integer constant?
0x1A
01A
1A
#1A
24
Which is the correct range for a signed char (assuming 1 byte)?
25
What is the associativity of the assignment operator =?
26 Which of the following is NOT a valid string constant?
"Hello"
"123"
'Hello'
""
27
What is the output of 5 / 2 in C (integer arithmetic)?
28 Which operator converts the bits of a number to their opposite (0 becomes 1, 1 becomes 0)?
!
~
^
-
29
What happens if you try to use the modulus operator % with floating-point numbers?
30
What is the value of x after: int x = 10; x = (x == 10);?
31 Which is the Bitwise XOR operator?
|
&
^
#
32
What is the result of 10 ^ 10?
33 Which of the following variables uses the PascalCase naming convention (though not enforced by C)?
myVariable
MyVariable
my_variable
MY_VARIABLE
34 Implicit type conversion is also known as:
35
What is the result of !0?
36
In the expression a = 5, b = 10, c = 15;, which operator is used?
37 Which of the following is a valid octal constant?
075
085
75
0x75
38 Which logical operator has the highest precedence?
&&
||
!
39
If int a = 10;, what is the value of a after a *= 2 + 3;?
40
Which header file is typically included to use printf?
conio.h
stdlib.h
stdio.h
math.h
41
What is the result of 1 < 2 < 3 in C?
42
What is the result of 3 < 2 < 1 in C?
43 Which of these characters represents the null terminator in a string?
\n
\0
\t
0
44 Short-circuit evaluation means:
&& or || is not evaluated if the result is determined by the first
45 Which is the correct way to write as a floating point constant?
2*10^3
2e3
2E-3
2000
46
What is the value of ~0 (assuming 2's complement arithmetic)?
47 Which operator is used to get the address of a variable?
*
&
->
@
48
What is the precision of a double relative to a float?
49 Can keywords be used as variable names if written in uppercase?
50 Which operator forces a specific type conversion manually?
(type)