Unit 1 - Practice Quiz
1 Which of the following is NOT a valid variable name definition in C?
2
Which standard library header is typically included to use the printf and scanf functions?
<stdio.h>
<stdlib.h>
<math.h>
<conio.h>
3 What is the result of the expression in C when both operands are integers?
4 Which of the following is a valid keyword in C?
constant
volatile
main
integer
5
What is the size of a char data type in C?
6 Which operator is used to calculate the remainder of an integer division?
7 What is the correct format specifier for a double-precision floating-point variable?
%c
%d
%f
%lf
8 Which of the following represents a hexadecimal constant in C?
0x12
12h
12x
012
9 Identify the ternary (conditional) operator.
==
?:
if-else
||
10 What is the result of the bitwise AND operation: ?
11 Which of the following is an invalid string constant?
"123"
""
'Hello'
"Hello"
12
What is the associativity of the assignment operator (=)?
13 Which of the following is a Relational Operator?
<<
&&
>=
=
14
What happens if you assign a float value $3.14$ to an int variable?
15 Which operator has the highest precedence?
16
What is the value of x after the following code executes?
int x = 5;
x += 10;
17 The logical NOT operator is represented by:
!=
^
~
!
18 Which escape sequence represents a newline?
\t
\a
\r
\n
19
Which data type would be best suited to store the value True or False in C99?
char
int
_Bool
float
20
What is the output of sizeof(double) on a standard 32-bit or 64-bit system?
21 Which of the following creates an octal constant?
o
#
8
0 (zero)
22
Evaluate: 10 && 0
23
What does the increment operator ++ do?
24
Consider int a = 10; int b = a++;. What are the values of a and b?
25 Which operator is used to perform a Left Shift?
<
<<
<<<
>>
26
What is the range of a signed char?
27 Which of the following is NOT a C unary operator?
sizeof
%
& (Address of)
++
28
The expression a = (b = 5, b + 2) results in a having the value:
29
What is the result of 1 ^ 1 in C?
30 How are comments written in C (single line)?
// comment
/* comment
# comment
<!-- comment -->
31
Which header file is required to use INT_MAX?
<limits.h>
<stdio.h>
<conio.h>
<stdlib.h>
32
In the expression if (a > b && c > d), if a > b is false, what happens?
c > d is NOT evaluated.
c > d is evaluated next.
33
The sizeof operator returns the size in:
34
What is the decimal equivalent of the bitwise left shift 3 << 2?
35 Which of these identifiers follows the 'CamelCase' convention (often used, though snake_case is common in C)?
student_grade
StudentGrade
STUDENT_GRADE
studentgrade
36 Which operator performs a one's complement (inverts all bits)?
-
~
!
^
37
What is the correct syntax to declare a constant variable PI with value $3.14$?
constant float PI = 3.14;
var const PI = 3.14;
float const = 3.14 PI;
const float PI = 3.14;
38
What is the value of x? int x = 4 + 2 * 3;
39 Which character represents the null terminator in a C string?
NULL
'0'
'\0'
'\n'
40
If x = 5, what is x += x + x?
41 Which of these is a valid scientific notation constant in C?
2.3 x 10^-2
2.3^-2
2.3e-2
e2.3
42
The result of a relational operator (e.g., a < b) is always:
true or false keyword
43
What is the l-value in the statement a = 10;?
a
10
;
=
44 Which variable declaration would allow storage of the largest integer value?
short
int
unsigned int
unsigned long long
45
Evaluate the condition: !5
46
What is the associativity of the Logical OR operator ||?
47
What is the output of printf("%d", 'A'); assuming ASCII encoding?
65
97
A
48 Bitwise operators can operate on which type of variables?
int and char
float and double
void
49 Which of the following is NOT a C token?
50
What is the result of 10 % 3?