Search Tutorials


C Data Types MCQ Questions and Answers | JavaInUse

C Data Types MCQ Questions and Answers

Q. What is the type of the expression (5 + 3) / 2 in C?

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

Q. What is the output of the following code snippet?

int main() {
int x = 5;
int y = ++x + 3;
printf("%d %d\\n", x, y);
return 0;
}
A. 6 9
B. 7 9
C. 6 8
D. 7 8

Q. Which data type is suitable for storing a boolean value in C?

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

Q. What is the range of the short data type in C on a typical 32-bit system?

A. -32768 to 32767
B. -2147483648 to 2147483647
C. -128 to 127
D. -32768 to 32767

Q. What is the output of the following code snippet?

int main() {
unsigned int x = -5;
printf("%u\\n", x);
return 0;
}
A. 4294967291
B. 0
C. -5
D. The program will not compile.

Q. What is the size of the long long data type in C on a typical 64-bit system?

A. 32 bits
B. 64 bits
C. 16 bits
D. It depends on the compiler.

Q. What is the output of the following code snippet?

int main() {
float x = 3.14;
double y = x;
printf("%.2f %.2f\\n", x, y);
return 0;
}
A. 3.14 3.14
B. 3.00 3.14
C. 3.1400 3.1400
D. 3 3

Q. What is the output of the following code snippet?

#include <limits.h>
int main() {
printf("Minimum char value: %d\\n", CHAR_MIN);
return 0;
}
A. Minimum char value: -128
B. Minimum char value: 0
C. Minimum char value: -32768
D. Minimum char value: -2147483648





Q. What is the purpose of the void data type in C?

A. To declare a function that takes no parameters
B. To declare a variable that can hold any data type
C. To declare a pointer that can point to any data type
D. To declare a function that returns no value

Q. What is the output of the following code snippet?

int main() {
int x = 10;
int y = x++ - x;
printf("%d\\n", y);
return 0;
}
A. 9
B. 10
C. 11
D. The program will not compile.

Q. What is the size of the long double data type in C on a typical system?

A. 32 bits
B. 64 bits
C. 80 bits
D. It depends on the compiler.

Q. What is the output of the following code snippet?

int main() {
int x = 10;
int y = x += 5;
printf("%d %d\\n", x, y);
return 0;
}
A. 15 15
B. 10 15
C. 15 10
D. 10 10

Q. Which data type is suitable for storing a single character in C?

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

Q. What is the type of the expression (char) 5 + 'A' in C?

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

Q. What is the output of the following code?

int main()
{
    int x = 10;
    double y = 3.5;
    printf("%.2f", x / y);
    return 0;
}
A. 2.00
B. 2.86
C. 3.00
D. 3.50

Q. What is the range of the short data type in C?

A. -32768 to 32767
B. -128 to 127
C. -32768 to 65535
D. -2147483648 to 2147483647

Q. What is the size of the float data type in C?

A. 2 bytes
B. 4 bytes
C. 8 bytes
D. It depends on the platform

Q. What is the output of the following code?

int main()
{
    unsigned int x = -5;
    printf("%u", x);
    return 0;
}
A. 4294967291
B. -5
C. 0
D. The program will not compile

Q. What is the output of the following code?

int main()
{
    int x = 10;
    int y = 5;
    printf("%d", x << y);
    return 0;
}
A. 10
B. 32
C. 64
D. 1024

Q. What is the output of the following code?

int main()
{
    int x = 15;
    int y = x & 7;
    printf("%d", y);
    return 0;
}
A. 0
B. 7
C. 8
D. 15

Q. What is the output of the following code?

int main()
{
    int x = 12;
    int y = x % 5;
    printf("%d", y);
    return 0;
}
A. 0
B. 2
C. 5
D. 12

Q. What is the output of the following code?

int main()
{
    int x = 10;
    int y = ++x;
    printf("%d %d", x, y);
    return 0;
}
A. 10 10
B. 11 10
C. 10 11
D. 11 11

Q. What is the output of the following code?

int main()
{
    int x = 5;
    int y = x++;
    printf("%d %d", x, y);
    return 0;
}
A. 5 5
B. 5 6
C. 6 5
D. 6 6

Q. What is the output of the following code?

int main()
{
    int x = 10;
    int y = x >> 2;
    printf("%d", y);
    return 0;
}
A. 2
B. 4
C. 8
D. 16

Q. What is the output of the following code?

int main()
{
    int x = 5;
    int y = x * x;
    printf("%d", y);
    return 0;
}
A. 10
B. 15
C. 25
D. 30

Q. What is the output of the following code?

int main()
{
    int x = 10;
    int y = x / 2;
    printf("%d", y);
    return 0;
}
A. 0
B. 2
C. 5
D. 10

Q. What is the output of the following code?

int main()
{
    int x = 12345;
    printf("%d", x / 1000);
    return 0;
}
A. 0
B. 1
C. 12
D. 123

Q. What is the output of the following code?

int main()
{
    int x = 10;
    int y = x + 5;
    printf("%d", y - x);
    return 0;
}
A. 0
B. 5
C. 10
D. 15