C Programming and Problem Solving Questions and Answers 101 to 110

C Programming and Problem Solving

Questions 101 to 110



101.
The storage class controls
(a)
Life time of a variable
(b)
Linkage of a variable
(c)
Scope of a variable
(d)
Both (a) and (c) above
(e)
(a), (b) and (c) above.
102.
Which storage class specifies local variables?
(a)
Auto
(b)
Register
(c)
Internal static
(d)
Both (a) and (c) above
(e)
(a), (b) and (c) above.
103.
int  array[3][2][2] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does array[2][1][0] in the above array contain?
(a)
5
(b)
7
(c)
9
(d)
11
(e)
15.
104.
What is the result for the following declaration?
int  array[] = { 1, 2, 3, 4, 5 };
printf( “%d”, &array[4] - &array[0] );
(a)
4
(b)
-4
(c)
8
(d)
-8
(e)
Undefined as the address of the array is not given.
105.
A function with no definition
(a)
Is an invalid function
(b)
Produces syntax error
(c)
Results into runtime error
(d)
Is allowed and is known as dummy function
(e)
Returns zero value.
106.
Functions have
(a)
Local scope
(b)
Block scope
(c)
File scope
(d)
Function scope
(e)
No scope at all.
107.
Given b=110 and c=20, what is the value of ‘a’ after execution of the expression               a=b-=c*=5?
(a)
10
(b)
450
(c)
110
(d)
-10
(e)
-110.
108.
What does the declaration mean?
float  *(*a[5]) ( )[3];
(a)
Pointer to an array[3] of function returning an array[5] of float
(b)
Array[5] of pointer to function returning an array[3] of float
(c)
Pointer to an array[5] of function returning an array[3] of float
(d)
Array[3] of pointer to function returning an array[5] of float
(e)
Invalid declaration.
109.
What is the base data type of a pointer variable by which the memory would be allocated to it?
(a)
Int
(b)
Float
(c)
No data type
(d)
Depends upon the type of the variable to which it is pointing
(e)
Unsigned int.
110.
Which of the following function calculates the square of ‘X’ in C?
(a)
sqr( X )
(b)
pow( 2, X)
(c)
pow( X, 2)
(d)
power( 2, X)
(e)
power( X, 2).

Answers


101.
Answer : (e)
Reason : According to the definition of storage classes they used to define (a), (b) and (c).
102.
Answer : (e)
Reason : As the auto, register and internal static variables are always the local variables.
103.
Answer : (d)
Reason : According to the memory allocation of array, three rows are there as each row having 2*2 dimension matrix.
104.
Answer : (a)
Reason : As it is the difference of the addresses at blocks 4 and 0, whatsoever the address of array may be.
105.
Answer : (d)
Reason : According to the ANSI C rules.
106.
Answer : (c)
Reason : According to the rules for the functions.
107.
Answer : (a)
Reason : As the expression is evaluated from right to left.
108.
Answer : (b)
Reason : According to the syntax rules for pointers and pointer to functions.
109.
Answer : (e)
Reason : As pointer holds the addresses and an address can never be a negative value.
110.
Answer : (c)
Reason : As this is the function whose prototype is defined in math.c.



<< Prev 1...  2...  3...  4...  5...  6...  7...  8...  9...  10...  11... 12...  13...  14...  15...  16...  17...  18...  19...  20...  21...  22...  23...  24...  25...  26...  27...  28...  29...  30...  31...  32...  33...  34...  35...  36...  Next >>


2 comments :