Font size
S
M
L
XL
WorksheetsHitha C Quiz 1
Total questions: 96
Worksheet time: 1hrs 12mins
Name
Class
Date
1.
C Programming – Features & The First C Program -- Which of the following is NOT a characteristic of C programming?
a)
Machine-independent
b)
High-level language
c)
Primarily object-oriented
d)
Structured programming language
2.
C Programming – Features & The First C Program -- What is the main function of the preprocessor directive `#include <stdio.h>`?
a)
Links the standard input/output library
b)
Defines a new function
c)
Declares a global variable
d)
Includes user-defined headers
3.
C Programming – Features & The First C Program -- What is the purpose of the `main()` function in a C program?
a)
It's an optional function
b)
It's the entry point of execution
c)
It declares global variables
d)
It handles error logging
4.
C Programming – Features & The First C Program -- Which of the following is the correct way to end a C statement?
a)
A colon (:)
b)
A semicolon (;)
c)
A period (.)
d)
A comma (,)
5.
C Programming – Features & The First C Program -- Which of the following is a key feature of C that allows direct memory manipulation?
a)
Garbage collection
b)
Pointers
c)
Virtual memory
d)
Polymorphism
6.
Introduction to Variables -- What is a variable in C?
a)
A fixed value that cannot be changed
b)
A named storage location in memory
c)
A function that performs a specific task
d)
A predefined keyword in the language
7.
Introduction to Variables -- Which of the following is a valid declaration of an integer variable in C?
a)
`int 1num;`
b)
`_int num;`
c)
`int num;`
d)
`integer num;`
8.
Introduction to Variables -- What is the initial value of a local variable if it's not explicitly initialized?
a)
Zero
b)
Garbage value
c)
Null
d)
1
9.
Variable Naming Conventions -- Which of the following is NOT a valid C identifier?
a)
`my_variable`
b)
`_count`
c)
`2nd_try`
d)
`variableName`
10.
Variable Naming Conventions -- Which character is commonly used to separate words in multi-word variable names in C (snake_case)?
a)
Hyphen (-)
b)
Space ( )
c)
Underscore (_)
d)
Dot (.)
11.
Variable Naming Conventions -- According to common C naming conventions, what should the name of a constant typically be?
a)
All lowercase letters
b)
CamelCase
c)
All uppercase letters with underscores
d)
Starting with a digit
12.
Basic Output Function – printf -- What is the purpose of the `printf()` function in C?
a)
To read input from the user
b)
To perform mathematical calculations
c)
To display output on the console
d)
To declare variables
13.
Basic Output Function – printf -- What is the correct format specifier for printing an integer using `printf()`?
a)
`%f`
b)
`%d`
c)
`%c`
d)
`%s`
14.
Basic Output Function – printf -- What will be the output of `printf("Hello\nWorld");`?
a)
`Hello World`
b)
`HelloWorld`
c)
`Hello` followed by `World` on a new line
d)
`HelloWorld` on a new line
15.
Fundamental Data Types − Integer (Part 1) -- Which keyword is used to declare an integer data type in C?
a)
`integer`
b)
`int`
c)
`num`
d)
`long`
16.
Fundamental Data Types − Integer (Part 1) -- What is the typical size of an `int` data type in bytes on a 32-bit system?
a)
1 byte
b)
2 bytes
c)
4 bytes
d)
8 bytes
17.
Fundamental Data Types − Integer (Part 1) -- Which of the following integer types guarantees to hold at least values up to 32767?
a)
`short int`
b)
`int`
c)
`long int`
d)
`char`
18.
Fundamental Data Types − Integer (Part 2) -- What is the purpose of the `unsigned` keyword with integer data types?
a)
Allows negative values only
b)
Increases the maximum positive range
c)
Decreases the maximum positive range
d)
Stores floating-point numbers
19.
Fundamental Data Types − Integer (Part 2) -- What is the default signedness of an `int` variable if `signed` or `unsigned` is not specified?
a)
`unsigned`
b)
`signed`
c)
Compiler dependent
d)
Error
20.
Fundamental Data Types − Integer (Part 2) -- Which data type would you use for a very large integer that needs to store a range greater than a standard `long int`?
a)
`short int`
b)
`long long int`
c)
`float`
d)
`double`
21.
Exceeding The Valid Range of Data Types -- What happens if you assign a value larger than the maximum capacity of an `unsigned char`?
a)
Compiler error
b)
Runtime error
c)
Wrap around (overflow)
d)
Undefined behavior
22.
Exceeding The Valid Range of Data Types -- What is "integer overflow" in C?
a)
The integer value becomes zero
b)
The integer value becomes negative
c)
The integer value exceeds its maximum representable value
d)
The integer value becomes a floating-point number
23.
Exceeding The Valid Range of Data Types -- What can be a consequence of integer overflow in security-critical applications?
a)
Improved performance
b)
No effect
c)
Vulnerabilities like buffer overflows
d)
More accurate calculations
24.
Fundamental Data Types − Character -- Which data type is used to store a single character in C?
a)
`string`
b)
`char`
c)
`text`
d)
`byte`
25.
Fundamental Data Types − Character -- What is the typical size of a `char` data type in bytes?
a)
1 byte
b)
2 bytes
c)
4 bytes
d)
8 bytes
26.
Fundamental Data Types − Character -- In C, single characters are enclosed in:
a)
Double quotes ("")
b)
Parentheses (())
c)
Single quotes ('')
d)
Square brackets ([])
27.
Fundamental Data Types − Float, Double & Long Double -- Which data type is used to store single-precision floating-point numbers?
a)
`double`
b)
`int`
c)
`float`
d)
`long double`
28.
Fundamental Data Types − Float, Double & Long Double -- What is the typical size of a `double` data type in bytes?
a)
4 bytes
b)
8 bytes
c)
16 bytes
d)
2 bytes
29.
Fundamental Data Types − Float, Double & Long Double -- Which of the following provides the highest precision for floating-point numbers?
a)
`float`
b)
`double`
c)
`long double`
d)
`int`
30.
Fundamental Data Types − Float, Double & Long Double -- What format specifier is used to print a `float` value using `printf()`?
a)
`%d`
b)
`%lf`
c)
`%c`
d)
`%f`
31.
Fundamental Data Types − Float, Double & Long Double -- What is a potential issue when comparing two floating-point numbers directly for equality?
a)
They are always equal
b)
Precision errors can lead to unexpected results
c)
It's not allowed in C
d)
It's much faster than integer comparison
32.
C Programming (Important Questions Set 1) -- Which of the following is a valid comment in C?
a)
`// This is a comment`
b)
`/* This is a comment */`
c)
`# This is a comment`
d)
Both A and B
33.
C Programming (Important Questions Set 1) -- Which header file is typically included for mathematical functions like `sqrt()` or `pow()`?
a)
`<stdio.h>`
b)
`<stdlib.h>`
c)
`<string.h>`
d)
`<math.h>`
34.
C Programming (Important Questions Set 1) -- What is the primary difference between a declaration and a definition in C?
a)
A declaration allocates memory, a definition does not.
b)
A definition allocates memory, a declaration does not.
c)
There is no difference.
d)
A declaration is always global, a definition is always local.
35.
C Programming (Important Questions Set 1) -- What is the purpose of the `return 0;` statement at the end of the `main()` function?
a)
Indicates an error occurred
b)
Indicates successful program execution
c)
Loops the program indefinitely
d)
Clears the console screen
36.
C Programming (Important Questions Set 1) -- Which of the following is considered a keyword in C?
a)
`main`
b)
`printf`
c)
`break`
d)
`scanf`
37.
Scope of Variables - Local vs Global -- What is the scope of a variable declared inside a function?
a)
Global scope
b)
File scope
c)
Local scope
d)
Block scope
38.
Scope of Variables - Local vs Global -- Where can a global variable be accessed?
a)
Only within the function it's declared in
b)
Only within the file it's declared in
c)
From any function in the program (if declared appropriately)
d)
Only by `main()`
39.
Scope of Variables - Local vs Global -- What is true about local variables?
a)
They persist throughout the program's execution.
b)
They are initialized to zero by default.
c)
Their lifetime is limited to the block or function where they are defined.
d)
They can be accessed from any file.
40.
Scope of Variables - Local vs Global -- If a local variable and a global variable have the same name, which one takes precedence within the function?
a)
The global variable
b)
The local variable
c)
Neither, it's a compiler error
d)
Both are accessible via different syntax
41.
Variable Modifiers − Auto & Extern -- Which storage class specifier is the default for local variables?
a)
`static`
b)
`extern`
c)
`auto`
d)
`register`
42.
Variable Modifiers − Auto & Extern -- What is the primary purpose of the `extern` keyword?
a)
To declare a variable that is initialized at runtime
b)
To indicate that a variable is defined in another file
c)
To make a variable accessible only within a specific function
d)
To force a variable to be stored in CPU registers
43.
Variable Modifiers − Auto & Extern -- Can an `auto` variable be initialized explicitly?
a)
No, they are always initialized to zero.
b)
No, they are always initialized to garbage values.
c)
Yes, they can be initialized with any valid expression.
d)
Only with constants.
44.
Variable Modifiers − Auto & Extern -- If you want to access a global variable from another C source file, which keyword is essential in the file where you want to use it?
a)
`static`
b)
`auto`
c)
`extern`
d)
`register`
45.
Variable Modifiers − Register -- What is the purpose of the `register` storage class specifier?
a)
To store a variable in main memory
b)
To suggest to the compiler to store the variable in a CPU register for faster access
c)
To make a variable globally accessible
d)
To initialize a variable to zero automatically
46.
Variable Modifiers − Register -- Can you take the address of a `register` variable using the `&` operator?
a)
Yes, always
b)
No, because they might not have a memory address
c)
Only if it's a global register variable
d)
Only if it's an array
47.
Variable Modifiers − Register -- When is the `register` keyword most effective?
a)
For large arrays
b)
For variables used frequently in a loop
c)
For global variables
d)
For variables that are rarely accessed
48.
Variable Modifiers − Static -- What is the lifetime of a `static` local variable?
a)
Until the function exits
b)
Throughout the program's execution
c)
Until the block it's in finishes
d)
Only for the current function call
49.
Variable Modifiers − Static -- What is the initial value of a `static` local variable if not explicitly initialized?
a)
Garbage value
b)
Undefined behavior
c)
Zero
d)
Null
50.
Variable Modifiers − Static -- What does `static` keyword mean when applied to a global variable or function?
a)
It restricts its visibility to the current file.
b)
It makes it accessible from anywhere in the program.
c)
It ensures it's stored in a CPU register.
d)
It makes it mutable.
51.
Constants in C -- How do you define a symbolic constant using the preprocessor in C?
a)
`const int MAX_VALUE = 100;`
b)
`#define MAX_VALUE 100`
c)
`enum { MAX_VALUE = 100 };`
d)
`static int MAX_VALUE = 100;`
52.
Constants in C -- What is the primary advantage of using `const` keyword over `#define` for defining constants?
a)
`const` constants can be changed at runtime.
b)
`const` constants are type-safe.
c)
`#define` is slower.
d)
`#define` cannot define numeric constants.
53.
Constants in C -- Which of the following is true about constants defined with `const`?
a)
They must be initialized at declaration.
b)
They can be modified later in the program.
c)
They are always stored in CPU registers.
d)
They have global scope by default.
54.
Constants in C -- Which type of constant is typically used for fixed values like PI (3.14159) or the speed of light?
a)
`volatile`
b)
`mutable`
c)
`const`
d)
`register`
55.
Constants in C -- What happens if you try to modify a variable declared with `const`?
a)
The program will run fine.
b)
It results in a compiler error.
c)
It results in a runtime error.
d)
The value will change, but with a warning.
56.
Introduction to Operators in C -- What is an operator in C?
a)
A keyword that defines a data type
b)
A symbol that performs an operation on one or more operands
c)
A function that prints output to the console
d)
A variable that stores a value
57.
Introduction to Operators in C -- Which category of operators works with a single operand?
a)
Binary operators
b)
Ternary operators
c)
Unary operators
d)
Logical operators
58.
Introduction to Operators in C -- What is operator precedence?
a)
The order in which operators are evaluated in an expression
b)
The number of operands an operator takes
c)
The type of values an operator returns
d)
The specific symbol used for an operator
59.
Introduction to Operators in C -- What is operator associativity?
a)
The direction in which operators of the same precedence are evaluated
b)
The number of operators in an expression
c)
The type of data an operator can handle
d)
Whether an operator is binary or unary
60.
Arithmetic Operators in C -- Which of the following is the division operator in C?
a)
`\`
b)
`//`
c)
`/`
d)
`%`
61.
Arithmetic Operators in C -- What is the result of `10 % 3` in C?
a)
3
b)
1
c)
3.33
62.
Arithmetic Operators in C -- What is the order of operations for arithmetic operators (from highest to lowest precedence)?
a)
`+`, `-`, `*`, `/`, `%`
b)
`*`, `/`, `%`, `+`, `-`
c)
`%`, `*`, `/`, `+`, `-`
d)
`+`, `*`, `/`, `-`, `%`
63.
Arithmetic Operators in C -- What will be the result of `5 + 2 * 3`?
a)
21
b)
11
c)
17
d)
15
64.
Increment and Decrement Operators in C -- What is the difference between `++i` (pre-increment) and `i++` (post-increment)?
a)
No difference, they are identical.
b)
`++i` increments `i` then uses its new value; `i++` uses `i`'s current value then increments it.
c)
`i++` increments `i` then uses its new value; `++i` uses `i`'s current value then increments it.
d)
`++i` is only for integers, `i++` for floats.
65.
Increment and Decrement Operators in C -- If `int x = 5;` what is the value of `y` after `int y = x++;`?
a)
6
b)
5
c)
4
d)
Undefined
66.
Increment and Decrement Operators in C -- If `int a = 7;` what is the value of `b` after `int b = --a;`?
a)
6
b)
7
c)
8
d)
Undefined
67.
Increment and Decrement Operators in C -- Which operator decreases the value of its operand by 1?
a)
`++`
b)
`-`
c)
`--`
d)
`+=`
68.
Relational Operators in C -- Which operator is used to check for equality in C?
a)
`=`
b)
`==`
c)
`!=`
d)
`<=>`
69.
Relational Operators in C -- What is the result of the expression `5 > 3` in C?
a)
`true`
b)
`false`
c)
`1`
d)
`0`
70.
Relational Operators in C -- Which operator checks if the left operand is less than or equal to the right operand?
a)
`<=`
b)
`=>`
c)
`<`
d)
`=>`
71.
Relational Operators in C -- What is the result of `(10 != 10)`?
a)
`1`
b)
`0`
c)
`true`
d)
`false`
72.
Logical Operators in C -- What is the result of `(true && false)` in C (assuming true is 1, false is 0)?
a)
`1`
b)
`0`
c)
`true`
d)
`false`
73.
Logical Operators in C -- Which operator negates a boolean expression (logical NOT)?
a)
`&`
b)
`|`
c)
`!`
d)
`^`
74.
Bitwise Operators in C -- Which operator performs a bitwise AND?
a)
`&&`
b)
`&`
c)
`|`
d)
`^`
75.
Bitwise Operators in C -- What is the result of `5 | 3` (bitwise OR)? (5 = 0101, 3 = 0011)
a)
7
b)
1
c)
5
d)
3
76.
Bitwise Operators in C -- Which operator is used for right shifting bits?
a)
`<<`
b)
`>>`
c)
`>>>`
d)
`<<<`
77.
Bitwise Operators in C -- What is the result of `10 << 1` (left shift by 1 bit)?
a)
5
b)
10
c)
20
d)
1
78.
Bitwise Operators in C -- What is the result of `16 >> 2` (right shift by 2 bits)?
a)
8
b)
4
c)
2
d)
1
79.
Bitwise Operators in C -- When would you typically use bitwise operators?
a)
For string manipulation
b)
For complex mathematical calculations
c)
For low-level operations like flag manipulation or optimizing certain calculations
d)
For database queries
80.
Assignment Operators in C -- Which operator is used for simple assignment in C?
a)
`==`
b)
`=`
c)
`!=`
d)
`:=`
81.
Assignment Operators in C -- What does the `+=` operator do?
a)
Subtracts and assigns
b)
Multiplies and assigns
c)
Adds and assigns
d)
Divides and assigns
82.
Assignment Operators in C -- If `x = 10;` and `x -= 3;`, what is the new value of `x`?
a)
7
b)
13
c)
30
d)
-3
83.
Assignment Operators in C -- What is the equivalent of `y /= 2;`?
a)
`y = y * 2;`
b)
`y = y / 2;`
c)
`y = 2 / y;`
d)
`y = y % 2;`
84.
Assignment Operators in C -- Which assignment operator is used for bitwise AND and assign?
a)
`&`
b)
`&=`
c)
`&&=`
d)
`|=`
85.
Assignment Operators in C -- If `a = 5;` and `a <<= 2;`, what is the new value of `a`?
a)
20
b)
10
c)
2
d)
5
86.
Assignment Operators in C -- What is the most common use case for the compound assignment operators?
a)
To create new variables
b)
To simplify and shorten code involving an operation and assignment
c)
To define constants
d)
To compare values
87.
C Programming (Important Questions Set 1) -- Which of the following is NOT a fundamental data type in C?
a)
`int`
b)
`char`
c)
`string`
d)
`float`
88.
C Programming (Important Questions Set 1) -- What is the correct syntax for declaring a variable `age` of type integer?
a)
`declare int age;`
b)
`int age;`
c)
`age = int;`
d)
`integer age;`
89.
C Programming (Important Questions Set 1) -- What is the purpose of the `scanf()` function?
a)
To print formatted output to the console
b)
To read formatted input from the standard input (keyboard)
c)
To perform mathematical calculations
d)
To include header files
90.
C Programming (Important Questions Set 1) -- Which escape sequence is used to represent a tab character?
a)
`\n`
b)
`\t`
c)
`\r`
d)
`\\`
91.
C Programming (Important Questions Set 1) -- What is the role of a compiler in C programming?
a)
To execute the program directly
b)
To convert source code into machine code
c)
To debug the program
d)
To manage memory allocation
92.
C Programming (Important Questions Set 1) -- Which of the following is a logical error?
a)
Missing a semicolon at the end of a statement
b)
Dividing by zero in a program
c)
Using an undeclared variable
d)
Incorrect function call syntax
93.
C Programming (Important Questions Set 1) -- What is a header file in C?
a)
A file containing the `main()` function
b)
A file containing pre-written declarations of functions and macros
c)
A file used for storing program output
d)
A file containing user input
94.
C Programming (Important Questions Set 1) -- What is the role of `void` in `void main()` or `void func()`?
a)
It specifies that the function returns an integer.
b)
It indicates that the function takes no arguments or returns no value.
c)
It makes the function global.
d)
It makes the function static.
95.
C Programming (Important Questions Set 1) -- Which of the following describes a "bug" in programming?
a)
A feature that makes the program faster
b)
An error or flaw in a computer program that causes it to produce an incorrect or unexpected result, or to behave in unintended ways
c)
A new software update
d)
A type of data storage
96.
C Programming (Important Questions Set 1) -- What is the difference between an lvalue and an rvalue?
a)
An lvalue refers to a value, an rvalue refers to a memory location.
b)
An lvalue refers to a memory location, an rvalue refers to a value.
c)
An lvalue is always a constant, an rvalue is always a variable.
d)
There is no difference.
Reset
