C Multiple Choice Questions: C Programming MCQ

C Multiple Choice Questions. C Programming Language MCQs, Questions regarding Declarations and Initialization. 

 

C Multiple Choice Questions

 

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;

 

Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ??

a. rem = 3.14 % 2.1;
b. rem = modf(3.14, 2.1);
c. rem = fmod(3.14, 2.1);
d. Remainder cannot be obtain in floating point division

 

Which of the following correctly represents a long double constant ??

a. 6.68
b. 6.68L
c. 6.68f
d. 6.68LF

 

What are the types of linkages ??

a. Internal and External
b. External, Internal, and None
c. External and None
d. Internal

 

Which of the following special symbol allowed in a variable name ??

a. * (asterisk)
b. | (pipeline)
c. – (hyphen)
d. _ (underscore)

 

1 : typedef long a;
extern int a c;
2 : typedef long a;
extern a int c;
3 : typedef long a;
extern a c;

a. 1 correct
b. 2 correct
c. 3 correct
d. 1, 2, 3 are correct

 

Is there any difference between the following declarations ??

a. extern int fun();
b. int fun();
c. Both are identical
d. No difference, except extern int fun(); is probably in another file

 

A long double can be used if the range of a double is not enough to accommodate a real number ??

a. True
b. False
c. –
d. –

 

How would you round off a value from 1.66 to 2.0 ??

a. ceil(1.66)
b. floor(1.66)
c. roundup(1.66)
d. roundto(1.66)

 

A float is 4 bytes wide, whereas a double is 8 bytes wide ??

a. True
b. False
c. –
d. –

 

C MCQs

 

By default, a real number is treated as a ??

a. float
b. double
c. long double
d. far double

 

If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function ??

a. True
b. False
c. –
d. –

 

Identify which of the following are declarations ??
1 extern int x;
2 float square ( float x ) { … }
3 double pow(double, double);

a. 1
b. 2
c. 1 and 3

 

Size of short integer and long integer can be verified using the sizeof() operator ??

a. True
b. False
c. –
d. –

 

When do we mention the prototype of a function ??

a. Defining
b. Declaring
c. Prototyping
d. Calling

 

Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform (Turbo C under DOS) ??

a. True
b. False
c. –
d. –

 

Size of short integer and long integer would vary from one platform to another ??

a. True
b. False
c. –
d. –

 

Range of float id -2.25e+308 to 2.25e+308 ??

a. True
b. False
c. .
d. .

 

Associativity has no role to play unless the precedence of the operator is the same ??

a. True
b. False
c. –
d. –

 

Is there any difference in the following declarations ??
1 int myfun(int arr[]);
2 int myfun(arr[20]);

a. Yes
b. No
c. –
d. –

 

C Multiple Choice Questions

 

The expression of the right-hand side of || operators doesn’t get evaluated if the left-hand side determines the outcome ??

a. True
b. False
c. –
d. –

 

Suppose a program is divided into three files f1, f2, and f3, and a variable is defined in the file f1 but used in files f2 and f3. In such a case would we need the extern declaration for the variables in the files f2 and f3 ??

a. Yes
b. No
c. –
d. –

 

In the expression a=b=5 the order of Assignment is NOT decided by the Associativity of operators ??

a. True
b. False
c. –
d. –

 

A global variable is available to all functions. Does there exist a mechanism by way of which is available to some and not to others ??

a. Yes
b. No
c. –
d. –

 

Associativity of an operator is either Left to Right or Right to Left ??

a. True
b. False
c. –
d. –

 

Is it true that a global variable may have several declarations, but only one definition ??

a. Yes
b. No
c. –
d. –

 

Are the following two statements the same ??
1. a <= 20 ? (b = 30): (c = 30);
2. (a <=20) ? b : (c = 30);

a. Yes
b. No

 

Is it true that a function may have several declarations, but only one definition ??

a. Yes
b. No

 

Two different operators would always have different associativity ??

a. Yes
b. No

 

Which of the following is the correct order of evaluation for the below expression ??
z = x + y * z / 4 % 2 – 1

a. * / % + – =
b. = * / % + –
c. / * % – + =
d. * % / – + =

 

C Multiple Choice Questions

 

Will the expression *p = p be disallowed by the compiler ??

a. Yes
b. No

 

Which of the following correctly shows the hierarchy of arithmetic operations in C ??

a. / + * –
b. * – / +
c. + – / *
d. / * + –

 

Does every operator have associativity ??

a. Yes
b. No

 

Which of the following is the correct usage of conditional operators used in C ??

a. a>b ? c=30 : c=40
b. a>b ? c=30;
c. max = a>b ? a>c?a:c:b>c?b:c
d. return (a>b)?(a:b)

 

The keyword used to transfer control from a function back to the calling function is ??

a. switch
b. goto
c. go back
d. return

 

Which of the following is the correct order if calling functions in the below code ??
a = f1(23, 14) * f2(12/4) + f3();

a. f1, f2, f3
b. f3, f2, f1
c. Order may vary from compiler to compiler
d. None of above

 

What is the notation for the following functions ??

a. 1. KR Notation 2. ANSI Notation
b. 1. Pre ANSI C Notation 2. KR Notation
c. 1. ANSI Notation 2. KR Notation
d. 1. ANSI Notation 2. Pre ANSI Notation

 

Which of the following are unary operators in C ??
1. !
2. size of
3. ~
4. &&

a. 1, 2
b. 1, 3
c. 2, 4
d. 1, 2, 3

 

How many times the program will print “myAndroid” ??

a. Infinite times
b. 32767 times
c. 65535 times
d. Till stack overflows

 

In which order do the following get evaluated ??
1. Relational
2. Arithmetic
3. Logical
4. Assignment

a. 2134
b. 1234
c. 4321
d. 3214

 

C Multiple Choice Questions

 

What will be the output of the program in the 16-bit platform (Turbo C under DOS) ??

a. Garbage value
b. 0 (Zero)
c. 1990
d. No output

 

A function cannot be defined inside another function ??

a. True
b. False

 

How many bytes are occupied by near, far, and huge pointers (DOS) ??

a. near=2 far=4 huge=4
b. near=4 far=8 huge=8
c. near=2 far=4 huge=8
d. near=4 far=4 huge=8

 

Functions cannot return more than one value at a time ??

a. True
b. False

 

If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable ??

a. .
b. &
c. *
d. ->

 

C Multiple Choice Questions

 

If the return type for a function is not specified, it defaults to int ??

a. True
b. False

 

What would be the equivalent pointer expression for referring the array element a[i][j][k][l] ??

a. ((((a+i)+j)+k)+l)
b. *(*(*(*(a+i)+j)+k)+l)
c. (((a+i)+j)+k+l)
d. ((a+i)+j+k+l)

 

In C all functions except main() can be called recursively ??

a. True
b. False

 

A pointer is ??

a. A keyword used to create variables
b. A variable that stores the address of an instruction
c. A variable that stores the address of other variable
d. All of the above

 

Functions can be called either by value or reference ??

a. True
b. False

 

More MCQs on C Language

 

 

 

 

Leave a Comment

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

error: Content is protected !!