MCQ - Variables & Datatypes in C
11. What is size of int in C ?
A. 2 bytes
B. 4 bytes
C. 8 bytes
D. Depends on the system/compiler
View Answer
Ans : D
Explanation: The size of the datatypes depend on the system.The size of "int", in fact every other data type as well is compiler dependent and not language dependent. Based on how a compiler is implemented, it can take either 2 bytes or 4 bytes.
12. Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS)
A. TRUE
B. FALSE
C. May Be
D. Can't Say
View Answer
Ans : B
Explanation: The range of double is -1.7e+308 to 1.7e+308.
13. Which is false?
A. Constant variables need not be defined as they are declared and can be defined later
B. Global constant variables are initialized to zero
C. const keyword is used to define constant values
D. You cannot reassign a value to a constant variable
View Answer
Ans : A
Explanation: Since the constant variable has to be declared and defined at the same time, not doing it results in an error..
14. Array is ______ datatype in C Programming language.
A. Derived Data type
B. Primitive Data type
C. Custom Data type
D. None of these
View Answer
Ans : A
Explanation: Data types simply refers to the type and size of data associated with variables and functions.It is of two types :- Fundamental Data Types and Derived Data Types. Array is Derived Data type datatype in C Programming language.
15. If you pass an array as an argument to a function, what actually gets passed?
A. Address of last element of Array
B. Value of first element
C. Base address of array
D. Value of elements in array
View Answer
Ans : C
Explanation: Base address of array is passed.
16. When double is converted to float, the value is?
A. Rounded
B. Truncated
C. Depends on the standard
D. Depends on the compiler
View Answer
Ans : D
Explanation: When double is converted to float, the value will be Depends on the compiler.
17. Which of the following is not a logical operator?
A. !
B. &&
C. ||
D. |
View Answer
Ans : D
Explanation: && - Logical AND ! - Logical NOT || - Logical OR | - Bitwise OR(used in bitwise manipulations)
18. What is the output of this program?
#include <stdio.h>
int main(){
printf("%d",EOF);
return 0;
}
A. 0
B. 1
C. -1
D. NULL
View Answer
Ans : C
Explanation: EOF is macro which has been defined in stdio.h and it is equivalent to -1.
19. What is the output of this program?
#include <stdio.h>
int main(){
char num = ' 10';
printf("%d", num);
return 0;
}
A. 49
B. 48
C. 10
D. 8
View Answer
Ans : B
Explanation: It will print the ascii value of 0, i.e it will print the ascii value of last character always
20. What is the output of this program?
#include <stdio.h>
int main(){
void num=10;
printf("%v", num);
return 0;
}
A. Compilation error
B. 10
C. Garbage value
D. 0
View Answer
Ans : A
Explanation: Void is not a valid data type for declaring variables.
Also check :
Discussion