The ones who are crazy enough to think they can change the world are the ones who do.
- Steve Jobs

C Data Types Interview Questions and Answers

In most of the MNC interview questions such as in ZOHO interview question, IVTL Infoview interview questions, Amazon interview questions, GOOGLE interview questions, Infosys interview questions and even in Voonik interview questions, We come across several Tricky C Questions about which 2:5 of the questions are from data types in c. Solving that kind of tricky C questions is not an easy task for all C programmers. We need more practices to solve it with ease. So we provide 25+ interesting C questions in data types to make your MNC interview very easy.

Data Types Interview Questions

16. What will be the output of the C program ?

#include<stdio.h>
int main()
{
	char num = 127;
	num = num + 1;
	printf("%d", num);
	return 0;
}

A. garbage value

B. Compilation error

C. range out of bond

D. -128

x

 

Option: D

Explanation

Though a char is of ranging from -128 to 127. Whatever a integer number we are adding, it will loop through out its range. Thus after 127 the number is -128.

Answer


17. What will be the output of the C program ?

#include<stdio.h>
int main()
{
	extern int num;
	printf("%d", num);
	return 0;
}
int num = 10;

A. 10

B. Compilation error

C. Linker error

D. 0

x

 

Option: A

Explanation

extern is a keyword which can link to the variable declared even out of the program.

Answer


18. What will be the output of the C program?

#include<stdio.h>
int main()
{
	int size = sizeof(volatile) + sizeof(const);
	printf("%d",++size);
	return 0;
}

A. Compilation error

B. 4

C. Runtime error

D. 9

x

 

Option: D

Explanation

Volatile and const are C Keywords and their individual size is 4 bytes

Answer


19. What will be the output of the C program?

#include<stdio.h>
int main()
{
	static int num = 6;
	printf("%d ",num--);
	if(num)
	main();
	return 0;
}

A. Compilation Error

B. 6 5 4 3 2 1

C. 5 4 3 2 1

D. No output

x

 

Option: B

Explanation

Simply, function is looping again and again till num becomes 0 to exit the if condition.

Answer


20. What will be the output of the C program ?

#include<stdio.h>
int main()
{
	if (sizeof(char) > -12)
	printf("yes");
	else
	printf("No");
	return 0;
}

A. Compilation error

B. Yes

C. No

D. Runtime error

x

 

Option: C

Explanation

By default, all integer literals such as
-12
-56
23
are assigned as unsigned integer by C compiler. So if negative integers are given it will loop through its range 0 to 65,535. i.e) -12 is equal to 65524.

Answer


Report Us

We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.

Report