C Programming and Problem Solving Questions and Answers 221 to 230

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.
222.
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.
223.
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>.
224.
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.
225.
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.
226.
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.
227.
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).
228.
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.
229.
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.
230.
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.
222.
Answer : (d)
Reason:  First x becomes 5 and then x gets added to 2 and result is 7.
223.
Answer : (b)
Reason:  <stdio.h>
Header file contains the function prototypes for the standard input /output library functions and information used by them.
224.
Answer : (c)
Reason:  Function prototype is the declaration statement in  the calling program.
225.
Answer : (b)
Reason:  The value of i wll be 28 after execution of the code.
226.
Answer : (c)
Reason:  3 matches the case :3 and C will be printed.
227.
Answer : (c)
Reason:  C is the right  choice according to the statement .
228.
Answer : (c)
Reason:  Float occupies 4 bytes so total 8 bytes .
229.
Answer : (d)
Reason:  D is the right choice based on the recursive call.
230.
Answer : (d)
Reason:  Reasongetchr()function reads the character from the key board.
<< 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