This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1What is the purpose of typecasting?
Option C
Typecasting is the process of explicitly converting one data type into another so that a value can be used properly in an expression or calculation.
It allows the programmer to control how data behaves during operations, for example, converting an int to float to avoid loss of precision, or converting a float to int when only the whole number part is required.
Q: 2The declaration of C variable can be done
Option C
In traditional C, all variables must be declared before any action statement inside a block. An action statement is any statement that performs some operation, such as assignment, input-output, calculations, etc.
This means variable declarations must appear at the beginning of a block, usually right after the opening brace {.
Although modern C allows declaring variables anywhere in the program, the standard rule for basic C learning is that variables must be declared before writing any executable statements.
Q: 3How many variables can be initialized at a time?
Option D
In C language, you can initialize any number of variables at a time in a single statement, as long as they are separated by commas. For example,
int a = 11, b = 22, c = 33, d = 44, e = 55;
Q: 4In C, what are the various types of real data type (floating point data type)?
Option C
In C programming, floating point data types are used to represent real numbers, numbers that have fractional parts or decimals points.
| Data Type | Size (Typical) | Precision | Usage |
|---|---|---|---|
| float | 4 Bytes | 6-7 Decimal Digits | Single Precision |
| double | 8 Bytes | 15 Decimal Digits | Double Precision |
| long double | 10, 12 or 16 Bytes (Depends on Compiler) | 18 Decimal Digits | Extended Precision |
#include <stdio.h>
#include <float.h>
void main()
{
printf("Suraku Academy
");
printf("Size of float : %zu Bytes
", sizeof(float));
printf("Size of double : %zu Bytes
", sizeof(double));
printf("Size of long double : %zu Bytes
", sizeof(long double));
printf("Range and Precision:
");
printf("Float: Min : %e, Max : %e, Precision : %d Digits
",FLT_MIN, FLT_MAX, FLT_DIG);
printf("Double: Min : %e, Max : %e, Precision : %d Digits
",DBL_MIN, DBL_MAX, DBL_DIG);
printf("Long Double: Min : %Le, Max : %Le, Precision : %d digits
",LDBL_MIN, LDBL_MAX, LDBL_DIG);
}
Suraku Academy
Size of float : 4 Bytes
Size of double : 8 Bytes
Size of long double : 16 Bytes
Range and Precision:
Float: Min : 1.175494e-38, Max : 3.402823e+38, Precision : 6 Digits
Double: Min : 2.225074e-308, Max : 1.797693e+308, Precision : 15 Digits
Long Double: Min : 3.362103e-4932, Max : 1.189731e+4932, Precision : 18 digitsQ: 5Which is the data type not supported by C?
Option C
In standard C (C89/C90), there is no built-in boolean data type to store true/false values. Instead, programmers typically use integers to represent boolean values, where 0 (zero) means false and any non-zero value means true.
Q: 6Which of the following format specifiers can be used to read floating type values in C programming?
Option D
In C programming, when we deal with floating-point values (float or double), we use specific format specifiers inside printf() and scanf() function to write and read data respectively.
| Specifier | Purpose | Example |
|---|---|---|
| %f | Reads or writes floating-point numbers in decimal (fixed-point) notation. | 123.456000 |
| %e | Reads or writes floating-point numbers in scientific notation (exponential form). | 1.234560e+02 |
| %E | Same as %e, but uses uppercase E in scientific notation. | 1.234560E+02 |
| %g | Reads or writes floating-point numbers, automatically chooses between %f and %e, whichever is shorter. | 123.456 (for normal), 1.23e+06 (for large number) |
| %G | Same as %g, but uses uppercase E in scientific notation. | 123.456 or 1.23E+06 |
Q: 7The range of the numbers that can be represented in 8-bit using 2’s complement representation is
Option C
In 8-bit 2’s complement representation, the Most Significant Bit (MSB) acts as the sign bit, where 0 represents positive numbers and 1 represents negative numbers.
The range of numbers in 2’s complement is calculated as -2n-1 to 2n-1-1, where n is the number of bits.
For 8 bits (n=8):
Q: 8By default, a real number is treated as a?
Option B
In C, real numbers (numbers with a decimal point) are stored using floating-point types, float, double, and long double.
Whenever we write a real number like 43.14, -12.58, or 0.0010, the compiler automatically treats it as a double type unless you specify otherwise because a double has more precision compared to a float, which makes it suitable for most calculations.
If we want the number to be treated as a float, we must add the letter f at the end, like 73.18f, -89.74f.
Q: 9Implicit type conversion is
Option D
Implicit type conversion is a process in which the compiler automatically converts one data type to another during expression evaluation whenever needed.
This automatic conversion is also known as type promotion, because lower-ranked types are promoted to higher-ranked types like char to int, int to float to ensure consistency in operations. It happens without any explicit request from the programmer, unlike type casting (explicit type conversion), which is manually performed.
Q: 10The _________ qualifier is used when we want to work with both positive and negative values.
Option C
The qualifier or modifiers are the keywords used to modify or qualify the properties of data types. Four types of modifiers, they are:
Data type qualifiers help us control the range of values a variable can store. When we want a variable to hold both positive and negative values, we use the signed qualifier.
By default, most integer types are already signed, but we can also write it explicitly as signed int.
Q: 11Which of the following is incorrect variable name
Option D
All the given variable names follow the rules of C identifiers. So, all are valid variable name.
| VARIABLE NAME | EXPLANATION |
|---|---|
| name | Valid. Starts with a letter, contains only letters. |
| f_name | Valid. Underscore is allowed. |
| mob123 | Valid. Starts with a letter, digits allowed after letters. |
Q: 12The null character ‘