C Programming and Problem Solving Questions and Answers 111 to 120

C Programming and Problem Solving

Questions 111 to 120


111.
When a function is recursively called all the automatic variables are stored in a
(a)
Stack
(b)
Queue
(c)
Array
(d)
Linked List
(e)
Register.
112.
What would be the output for the following Turbo C code?
int   I, A[ ] = { 1, 2, 3, 4, 5 }, *P;
P = A;
++*P;
printf( “%d   ”, *P);
P += 2;
printf( “%d   ”, *P);
(a)
2   4
(b)
3   4
(c)
2   2
(d)
2   3
(e)
3   3.
113.
The number of arguments for realloc( ) function is/are
(a)
0
(b)
1
(c)
2
(d)
3
(e)
Depends op on user choice.
114.
int   A[4] = { 5, 6, 7, 8 };
Then which of the following will declare a pointer variable that points to the array in the sample declaration above?
(a)
int  *(ptr [4]) = &A;
(b)
int  (*ptr)[4] = &A;
(c)
int  ( ptr *)[4] = &A;
(d)
int  *ptr[4] = &A;
(e)
int  (*ptr[4]) = &A;.
115.
What would be the correct way to cast ‘ptr’ in the code above to be a pointer to a 3 element array of function pointers with a return value of int and a single parameter of a pointer to char?
(a)
( int ( ( * )[3] ) ( char * ) )ptr
(b)
( ( int * ) ( *[3] )( char * ) ) ptr
(c)
int *( [3]) ( * char * ) ptr
(d)
( int *( * )[3] ( char * ) )ptr
(e)
( int ( *( * )[3] )( char * ) )ptr.
116.
For the following structure declaration, find the correct statement.
struct  person {
       char name[20];
       int  age;
       struct person lady;
};
(a)
Is a valid nested structure
(b)
Uses an invalid data type
(c)
Is a self referential structure
(d)
Is not a valid nested structure
(e)
Is a self referential structure with invalid data type.
117.
The restriction with union is
(a)
The first member can only be initialized
(b)
The last member can only be initialized
(c)
Any member can be initialized
(d)
Union can not be initialized
(e)
No restriction at all.
118.
What are the two predefined FILE pointers in C?
(a)
console and error
(b)
stdout and stdio
(c)
stdout and stderr
(d)
stdio and stderr
(e)
console and stdio.
119.
Which is the fundamental data type used to implement the enum data type?
(a)
char
(b)
int
(c)
float
(d)
double
(e)
any primary data type including user defined data type.
120.
What would be the output if the following program( let months.c ) is run using the following command line arguments?
months   Jan   Feb  Mar   Apr
void main( int  no,  char *m[ ] )  {
       while(  no )  printf( “%s   ”,  m[--no] );
}
(a)
Error
(b)
No output at all
(c)
Jan   Feb  Mar   Apr
(d)
months   Jan   Feb  Mar   Apr
(e)
Apr   Mar   Feb   Jan   months.


Answers


111.
Answer : (a)
Reason : As internally an active record instance is created for every call and that ARI is pushed on the stack.
112.
Answer : (d)
Reason : Because the precedence of operators and prefix operation.
113.
Answer : (c)
Reason : As it takes two parameters, one is the pointer to the existing block and the second is the value for new size in integers.
114.
Answer : (b)
Reason : According to the syntax and semantics of pointers and pointers to the arrays.
115.
Answer : (e)
Reason : According to the syntax and semantics of pointers and pointers to the arrays.
116.
Answer : (d)
Reason : As we can not create a variable of itself as a member of the structure, but a reference can be created to create a self referential structure.
117.
Answer : (a)
Reason : As all the members shares the same memory.
118.
Answer : (c)
Reason : As console, error and stdio are not the predefined FILE pointers.
119.
Answer : (b)
Reason : According to the definition of enum.
120.
Answer : (e)
Reason : Because of the while loop and the initial value of no is 5.


<< 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 >>


No comments :

What you think about these Questions and Answers ? Let me know in comments.

Post a Comment