C MCQs for placement and exams - Set 4

C MCQs for placement and exams - Set 4


1.) By default a real number is treated as a
a.) float
b.) double
c.) long double
d.) far double
View Answer / Hide Answer

ANSWER: b.) double




2.) Is the following statement a declaration or definition?

extern int i;

a.) Declaration
b.) Definition
c.) Function
d.) Error
View Answer / Hide Answer

ANSWER: a.) Declaration




3.) Identify which of the following are declarations
a.) extern int x;
b.) float square ( float x ) { ... }
c.) double pow(double, double);
d.) None of these
View Answer / Hide Answer

ANSWER: Both a.) extern int x; & c.) double pow(double, double);




4.) When we mention the prototype of a function?
a.) Defining
b.) Declaring
c.) Prototyping
d.) Calling
View Answer / Hide Answer

ANSWER: b.) Declaring




5.) Which of the declaration is correct?
a.) int length
b.) char int
c.) int long
d.) float double
View Answer / Hide Answer

ANSWER: a.) int length




6.) Which of the following operations are INCORRECT?
a.) int i = 35; i = i%5
b.) short int j = 255; j = j
c.) long int k = 365L; k = k
d.) float a = 3.14; a = a%3
View Answer / Hide Answer

ANSWER: d.) float a = 3.14; a = a%3




7.) Which of the following correctly represents a long double constant?
a.) 6.68
b.) 6.68L
c.) 6.68f
d.) 6.68LF
View Answer / Hide Answer

ANSWER: b.) 6.68L




8.) What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array?
a.) The element will be set to 0.
b.) The compiler would report an error.
c.) The program may crash if some important data gets overwritten
d.) The array size would appropriately grow.
View Answer / Hide Answer

ANSWER: c.) The program may crash if some important data gets overwritten




9.) What does the following declaration mean?

int (*ptr)[10];

a.) ptr is array of pointers to 10 integers
b.) ptr is a pointer to an array of 10 integers
c.) ptr is an array of 10 integers
d.) ptr is an pointer to array
View Answer / Hide Answer

ANSWER: b.) ptr is a pointer to an array of 10 integers




10.) In C, if you pass an array as an argument to a function, what actually gets passed?
a.) Value of elements in array
b.) First element of the array
c.) Base address of the array
d.) Address of the last element of array
View Answer / Hide Answer

ANSWER: c.) Base address of the array


Post your comment