Data Types in C Programming: MCQs On Data Types in C

Data Types in C Programming. MCQs on the topic of Data Types in C programming Language.

Data Types in C Programming

 

What is short int in C programming ??

a) The basic data type of C
b) Qualifier
c) Short is the qualifier and int is the basic data type
d) All of the mentioned

 

Which of the data types has the size that is variable ??

a) int
b) struct
c) float
d) double

 

What is the size of an int data type ??

a) 4 Bytes
b) 8 Bytes
c) Depends on the system/compiler
d) Cannot be determined

 

Which is correct with respect to the size of the data types ??

a) char > int > float
b) int > char > float
c) char < int < double
d) double > char > int

Data Types in C Programming

 

Which of the following is a User-defined data type ??

a) typedef int Boolean;
b) typedef enum {Mon, Tue, Wed, Thu, Fri} Workdays;
c) struct {char name[10], int age};
d) all of the mentioned

 

Which data type is most suitable for storing a number 65000 in a 32-bit system ??

a) signed short
b) unsigned short
c) long
d) int

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
char c;
int i = 0;
FILE *file;
file = fopen(“test.txt”, “w+”);
fprintf(file, “%c”, ‘a’);
fprintf(file, “%c”, -1);
fprintf(file, “%c”, ‘b’);
fclose(file);
file = fopen(“test.txt”, “r”);
while ((c = fgetc(file)) != -1)
printf(“%c”, c);
return 0;
}

a) a
b) Infinite loop
c) Depends on what fgetc returns
d) Depends on the compiler

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
float x = ‘a’;
printf(“%f”, x);
return 0;
}

a) a
b) run time error
c) a.0000000
d) 97.000000

Data Types in C Programming

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
signed char chr;
chr = 128;
printf(“%d\n”, chr);
return 0;
}

a) 128
b) -128
c) Depends on the compiler
d) None of the mentioned

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
float f1 = 0.1;
if (f1 == 0.1f)
printf(“equal\n”);
else
printf(“not equal\n”);
}

a) equal
b) not equal
c) output depends on compiler
d) error

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
float f1 = 0.1;
if (f1 == 0.1)
printf(“equal\n”);
else
printf(“not equal\n”);
}

a) equal
b) not equal
c) output depends on the compiler
d) error

 

What will be the output of the following C code ??

#include <stdio.h>
int main()
{
int a[5] = {1, 2, 3, 4, 5};
int i;
for (i = 0; i < 5; i++)
if ((char)a[i] == ‘5’)
printf(“%d\n”, a[i]);
else
printf(“FAIL\n”);
}

a) The compiler will flag an error
b) The program will compile and print the output 5
c) The program will compile and print the ASCII value of 5
d) The program will compile and print FAIL for 5 times

Data Types in C Programming

 

What will be the output of the following C code on a 64 bit machine ??

#include <stdio.h>
union Sti
{
int nu;
char m;
};
int main()
{
union Sti s;
printf(“%d”, sizeof(s));
return 0;
}

a) 8
b) 5
c) 9
d) 4

 

What will be the output of the following C code on a 32-bit machine ??

#include <stdio.h>
int main()
{
int x = 10000;
double y = 56;
int *p = &x;
double *q = &y;
printf(“p and q are %d and %d”, sizeof(p), sizeof(q));
return 0;
}

a) p and q are 4 and 4
b) p and q are 4 and 8
c) compiler error
d) p and q are 2 and 8

 

The format identifier ‘%i’ is also used for _____ data type ??

a) char
b) int
c) float
d) double

 

More Posts

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!