C Programming and Problem Solving
Questions 221 to 230
221.
|
What result is in the variable num1 after execution of the
following statements?
int j = 1, num1 = 4;
while (++j <= 10)
{
num1++;
}
(a) 11 (b) 12 (c) 13 (d) 14 (e) 15.
|
What is the final value of x if initially x has the value
0?
if (x >= 0)
x += 5;
if (x
>= 5)
x += 2;
(a) 0 (b) 2 (c) 5 (d) 7 (e) 8.
|
|
Which header file contains the function prototypes for the
standard input /output library functions and information used by them?
(a) <std I/O.h> (b) <stdio.h> (c)
<stdlib.h> (d) <stdiolib.h> (e)
<studio.h>.
|
|
A function prototype is
(a) A definition of
the function
(b) A declaration
statement in the called program
(c) A declaration
statement in the calling program
(d) A function call
in the program
(e) A sterotype in
the program.
|
|
What is the value of i after this segment of the program
is executed?
n = 27;
i = 0;
for( i = 0; i <= n; i+= 2 ) {
printf(i );
}
(a) 25 (b) 28 (c) 27 (d) 26 (e) 29.
|
|
What is the value of the variable c after the switch
statement below?
x = 3;
switch (
x ) {
case 1 : c = 'A'; break;
case 2 : c = 'B'; break;
case 3 : c = 'C'; break;
default: c = 'F'; break;
}
(a) S (b) B (c) C (d) F (e) AB.
|
|
Which of the following is the function prototype of a
function f1 that receives an int pointer and float reference and returns an
int pointer?
(a) int
f1(int &, float *) (b) float* f1(float &, int &)
(c) int* f1 (int *, float &) (d) int f1 *(int *, float &)
(e) int f1(&int,*float).
|
|
Consider the following declaration :float a, b;
How
much memory will be reserved for the above two declared variables.
(a) 1 byte (b) 4 bytes (c) 8 bytes (d) 16 bytes (e) 20 bytes.
|
|
What is the return value of the following function if the
function is called as
int value = fun(6);
int fun(int n)
{
if( n = = 1 ||
n = = 2) return
1;
else
return( fun(n-1) + fun(n-2) );
}
(a) 1 (b) 2 (c) Syntax error (d) 8 (e) 5.
|
|
The getchar() function reads a
(a) String from a file (b) Character from a file
(c) String from the keyboard (d) Character from the keyboard
(e) Word from the file.
|
Answers
221.
|
Answer : (d)
Reason: 14 is the
right choice after the execution of program.
|
Answer : (d)
Reason: First x
becomes 5 and then x gets added to 2 and result is 7.
|
|
Answer : (b)
Reason: <stdio.h>
Header file contains the function prototypes for the
standard input /output library functions and information used by them.
|
|
Answer : (c)
Reason: Function
prototype is the declaration statement in
the calling program.
|
|
Answer : (b)
Reason: The value of
i wll be 28 after execution of the code.
|
|
Answer : (c)
Reason: 3 matches the
case :3 and C will be printed.
|
|
Answer : (c)
Reason: C is the
right choice according to the
statement .
|
|
Answer : (c)
Reason: Float occupies
4 bytes so total 8 bytes .
|
|
Answer : (d)
Reason: D is the
right choice based on the recursive call.
|
|
Answer : (d)
Reason: Reasongetchr()function
reads the character from the key board.
|
Very nice post. Also Learn from the adaptable online videos, revision lectures and course materials on C Programming for Problem Solving.
ReplyDeletesab ans galat hai idhar,dont come
ReplyDelete