100 Multiple choice questions in C

Discussion in 'C' started by coderzone, Apr 2, 2006.

  1. /*question number 1*/
    Code:
    int z,x=5,y=-10,a=4,b=2;
    z = x++ - --y * b / a;
    What number will z in the sample code above contain?
    Choice 1
    5
    Choice 2
    6
    Choice 3
    10 [Ans] Corrected by buddy by running the program
    Choice 4
    11
    Choice 5
    12
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 2*/
    With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed?
    Choice 1
    unalloc()
    Choice 2
    dropmem()
    Choice 3
    dealloc()
    Choice 4
    release()
    Choice 5
    free() [Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 3*/
    Code:
    void *ptr;
    myStruct myArray[10];
    ptr = myArray; 
    Which of the following is the correct way to increment the variable "ptr"?
    Choice 1
    ptr = ptr + sizeof(myStruct); [Ans]
    Choice 2
    ++(int*)ptr;
    Choice 3
    ptr = ptr + sizeof(myArray);
    Choice 4
    increment(ptr);
    Choice 5
    ptr = ptr + sizeof(ptr);
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 4*/
    Code:
    char* myFunc (char *ptr)
    {
    ptr += 3;
    return (ptr);
    }
    int main()
    {
    char *x, *y;
    x = "HELLO";
    y = myFunc (x);
    printf ("y = %s \n", y);
    return 0;
    }
    
    What will print when the sample code above is executed?
    Choice 1
    y = HELLO
    Choice 2
    y = ELLO
    Choice 3
    y = LLO
    Choice 4
    y = LO [Ans]
    Choice 5
    x = O
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 5*/
    Code:
    struct node *nPtr, *sPtr;    /* pointers for a linked list. */
    for (nPtr=sPtr; nPtr; nPtr=nPtr->next)
    {   
    free(nPtr);
    }
    
    The sample code above releases memory from a linked list. Which of the choices below accurately describes how it will work?
    Choice 1
    It will work correctly since the for loop covers the entire list.
    Choice 2
    It may fail since each node "nPtr" is freed before its next address can be accessed.
    Choice 3
    In the for loop, the assignment "nPtr=nPtr->next" should be changed to "nPtr=nPtr.next".
    Choice 4
    This is invalid syntax for freeing memory.
    Choice 5
    The loop will never end.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 6*/
    What function will read a specified number of elements from a file?
    Choice 1
    fileread()
    Choice 2
    getline()
    Choice 3
    readfile()
    Choice 4
    fread()
    Choice 5
    gets()
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 7*/
    "My salary was increased by 15%!"
    Select the statement which will EXACTLY reproduce the line of text above.
    Choice 1
    printf("\"My salary was increased by 15/%\!\"\n");
    Choice 2
    printf("My salary was increased by 15%!\n");
    Choice 3
    printf("My salary was increased by 15'%'!\n");
    Choice 4
    printf("\"My salary was increased by 15%%!\"\n");[Ans]
    Choice 5
    printf("\"My salary was increased by 15'%'!\"\n");
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 8*/
    What is a difference between a declaration and a definition of a variable?
    Choice 1
    Both can occur multiple times, but a declaration must occur first.
    Choice 2
    There is no difference between them.
    Choice 3
    A definition occurs once, but a declaration may occur many times.
    Choice 4
    A declaration occurs once, but a definition may occur many times. [Ans]
    Choice 5
    Both can occur multiple times, but a definition must occur first.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 9*/
    int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
    What value does testarray[2][1][0] in the sample code above contain?
    Choice 1
    3
    Choice 2
    5
    Choice 3
    7
    Choice 4
    9
    Choice 5
    11[Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 10*/
    Code:
    int a=10,b;
    b=a++ + ++a;
    printf("%d,%d,%d,%d",b,a++,a,++a);
    
    what will be the output when following code is executed
    Choice 1
    12,10,11,13
    Choice 2
    22,10,11,13
    Choice 3
    22,11,11,11
    Choice 4
    12,11,11,11
    Choice 5
    22,13,13,13[Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 11*/
    Code:
    int x[] = { 1, 4, 8, 5, 1, 4 };
    int *ptr, y;
    ptr  = x + 4;
    y = ptr - x; 
    
    What does y in the sample code above equal?
    Choice 1
    -3
    Choice 2
    0
    Choice 3
    4[Ans]
    Choice 4
    4 + sizeof( int )
    Choice 5
    4 * sizeof( int
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 12*/
    Code:
    void myFunc (int x)
    {
       if (x > 0)
       myFunc(--x);
       printf("%d, ", x);
    }
    int main()
    {
       myFunc(5);
       return 0;
    } 
    
    What will the above sample code produce when executed?
    Choice 1
    1, 2, 3, 4, 5, 5,
    Choice 2
    4, 3, 2, 1, 0, 0,
    Choice 3
    5, 4, 3, 2, 1, 0,
    Choice 4
    0, 0, 1, 2, 3, 4, [Ans]
    Choice 5
    0, 1, 2, 3, 4, 5,
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 13*/
    11 ^ 5
    What does the operation shown above produce?
    Choice 1
    1
    Choice 2
    6
    Choice 3
    8
    Choice 4
    14 [Ans]
    Choice 5
    15
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 14*/
    #define MAX_NUM 15
    Referring to the sample above, what is MAX_NUM?
    Choice 1
    MAX_NUM is an integer variable.
    Choice 2
    MAX_NUM is a linker constant.
    Choice 3
    MAX_NUM is a precompiler constant.
    Choice 4
    MAX_NUM is a preprocessor macro. [Ans]
    Choice 5
    MAX_NUM is an integer constant.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 15*/
    Which one of the following will turn off buffering for stdout?
    Choice 1
    setbuf( stdout, FALSE );
    Choice 2
    setvbuf( stdout, NULL );
    Choice 3
    setbuf( stdout, NULL );
    Choice 4
    setvbuf( stdout, _IONBF );
    Choice 5
    setbuf( stdout, _IONBF );
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 16*/
    What is a proper method of opening a file for writing as binary file?
    Choice 1
    FILE *f = fwrite( "test.bin", "b" );
    Choice 2
    FILE *f = fopenb( "test.bin", "w" );
    Choice 3
    FILE *f = fopen( "test.bin", "wb" );
    Choice 4
    FILE *f = fwriteb( "test.bin" );
    Choice 5
    FILE *f = fopen( "test.bin", "bw" );
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 17*/
    Which one of the following functions is the correct choice for moving blocks of binary data that are of arbitrary size and position in memory?
    Choice 1
    memcpy()
    Choice 2
    memset()
    Choice 3
    strncpy()
    Choice 4
    strcpy()
    Choice 5
    memmove()[Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 18*/
    int x = 2 * 3 + 4 * 5;
    What value will x contain in the sample code above?
    Choice 1
    22
    Choice 2
    26[Ans]
    Choice 3
    46
    Choice 4
    50
    Choice 5
    70
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 19*/
    Code:
    void * array_dup (a, number, size)
      const void * a;
      size_t number;
      size_t size;
    {
      void * clone;
      size_t bytes;
      assert(a != NULL);
      bytes = number * size;
      clone = alloca(bytes);
      if (!clone)
        return clone;
      memcpy(clone, a, bytes);
      return clone;
    } 
    
    The function array_dup(), defined above, contains an error. Which one of the following correctly analyzes it?
    Choice 1
    If the arguments to memcpy() refer to overlapping regions, the destination buffer will be subject to memory corruption.
    Choice 2
    array_dup() declares its first parameter to be a pointer, when the actual argument will be an array.
    Choice 3
    The memory obtained from alloca() is not valid in the context of the caller. Moreover, alloca() is nonstandard.
    Choice 4
    size_t is not a Standard C defined type, and may not be known to the compiler.
    Choice 5
    The definition of array_dup() is unusual. Functions cannot be defined using this syntax.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 20*/
    int var1;
    If a variable is declared as above, can it be accessed from another file?
    Choice 1
    Yes; it can be referenced.
    Choice 2
    No; it should be declared as a static variable.
    Choice 3
    No; it should be declared using the global keyword.[Ans]
    Choice 4
    Yes; it can be referenced through the publish specifier.
    Choice 5
    Yes; it can be referenced through the extern specifier.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 21*/
    time_t t;
    Which one of the following statements will properly initialize the variable t with the current time from the sample above?
    Choice 1
    t = clock();[Ans]
    Choice 2
    time( &t );
    Choice 3
    t = ctime();
    Choice 4
    t = localtime();
    Choice 5
    None of the above
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 22*/
    Which one of the following provides conceptual support for function calls?
    Choice 1
    The system stack[Ans]
    Choice 2
    The data segment
    Choice 3
    The processor's registers
    Choice 4
    The text segment
    Choice 5
    The heap
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    /*question number 23*/
    C is which kind of language?
    Choice 1
    Machine
    Choice 2
    Procedural[Ans]
    Choice 3
    Assembly
    Choice 4
    Object-oriented
    Choice 5
    Strictly-typed
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 24*/
    Code:
    int i,j;
    int ctr = 0;
    int myArray[2][3];
    for (i=0; i<3; i++)
       for (j=0; j<2; j++)
       {
          myArray[j][i] = ctr;
          ++ctr;
       } 
    
    What is the value of myArray[1][2]; in the sample code above?
    Choice 1
    1
    Choice 2
    2
    Choice 3
    3
    Choice 4
    4
    Choice 5
    5 [Ans] 00,10,01,11,12
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 25*/
    Code:
    int x = 0;
    for (x=1; x<4; x++);
    printf("x=%d\n", x); 
    
    What will be printed when the sample code above is executed?
    Choice 1
    x=0
    Choice 2
    x=1
    Choice 3
    x=3
    Choice 4
    x=4[Ans]
    Choice 5
    x=5
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 26*/
    Code:
    int x = 3;
    if( x == 2 );
      x = 0;
    if( x == 3 )
    x++;
    else x += 2; 
    
    What value will x contain when the sample code above is executed?
    Choice 1
    1
    Choice 2
    2[Ans]
    Choice 3
    3
    Choice 4
    4
    Choice 5
    5
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 27*/
    Code:
    char *ptr;
    char myString[] = "abcdefg";
    ptr = myString;
    ptr += 5; 
    
    What string does ptr point to in the sample code above?
    Choice 1
    fg [Ans]/*because string*/
    Choice 2
    efg
    Choice 3
    defg
    Choice 4
    cdefg
    Choice 5
    None of the above
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 28*/
    Code:
    double x = -3.5, y = 3.5;
    printf( "%.0f : %.0f\n", ceil( x ), ceil( y ) );
    printf( "%.0f : %.0f\n", floor( x ), floor( y ) ); 
    
    What will the code above print when executed?
    ceil =>rounds up 3.2=4 floor =>rounds down 3.2=3
    Choice 1
    -3 : 4
    -4 : 3 [Ans]
    Choice 2
    -4 : 4
    -3 : 3
    Choice 3
    -4 : 3
    -4 : 3
    Choice 4
    -4 : 3
    -3 : 4
    Choice 5
    -3 : 3
    -4 : 4
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 29*/
    Which one of the following will declare a pointer to an integer at address 0x200 in memory?
    Choice 1
    int *x;
    *x = 0x200;[Ans]
    Choice 2
    int *x = &0x200;
    Choice 3
    int *x = *0x200;
    Choice 4
    int *x = 0x200;
    Choice 5
    int *x( &0x200 );
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 30*/
    Code:
    int x = 5;
    int y = 2;
    char op = '*';
    switch (op)
    {
      default : x += 1;
      case '+' : x += y; /*It will go to all the cases*/
      case '-' : x -= y;
    } 
    
    After the sample code above has been executed, what value will the variable x contain?
    Choice 1
    4
    Choice 2
    5
    Choice 3
    6 [Ans]
    Choice 4
    7
    Choice 5
    8
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 31*/
    Code:
    x = 3, counter = 0;
    while ((x-1))
    {
       ++counter;
       x--;
    } 
    
    Referring to the sample code above, what value will the variable counter have when completed?
    Choice 1
    0
    Choice 2
    1
    Choice 3
    2[Ans]
    Choice 4
    3
    Choice 5
    4
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 32*/
    char ** array [12][12][12];
    Consider array, defined above. Which one of the following definitions and initializations of p is valid?
    Choice 1
    char ** (* p) [12][12] = array; [Ans]
    Choice 2
    char ***** p = array;
    Choice 3
    char * (* p) [12][12][12] = array;
    Choice 4
    const char ** p [12][12][12] = array;
    Choice 5
    char (** p) [12][12] = array;
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 33*/
    void (*func(int f, void (*handler) (int))) (int);
    Which one of the following definitions of funchandler_t allows the above declaration to be rewritten as follows:
    funchandler_t func (int f, funchandler_t handler);
    Choice 1
    typedef void (*funchandler_t) (int);[Ans]
    Choice 2
    typedef funchandler_t void (*) (int);
    Choice 3
    typedef void *funchandler_t (int);
    Choice 4
    #define funchandler_t(x) void (*x) (int)
    Choice 5
    #define funchandler_t void (*) (int)
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 34*/
    All of the following choices represent syntactically correct function definitions. Which one of the following represents a semantically legal function definition in Standard C?
    Choice 1
    Code:
    int count_digits (const char * buf) {
      assert(buf != NULL);
      int cnt = 0, i;
      for (i = 0; buf[i] != '\0'; i++)
        if (isdigit(buf[i]))
          cnt++;
     
    
    return cnt;
    } 
    
    Choice 2
    Code:
    int count_digits (const char * buf) {
      int cnt = 0;
      assert(buf != NULL);
      for (int i = 0; buf[i] != '\0'; i++)
        if (isdigit(buf[i]))
          cnt++;
      return cnt;
    } 
    
    Choice 3

    Code:
    int count_digits (const char * buf) {
      int cnt = 0, i;
      assert(buf != NULL);
      for (i = 0; buf[i] != '\0'; i++)
        if (isdigit(buf[i]))
          cnt++;
      return cnt;
    } 
    
    Choice 4

    Code:
    int count_digits (const char * buf) {
      assert(buf != NULL);
      for (i = 0; buf[i] != '\0'; i++)
        if (isdigit(buf[i]))
          cnt++;
      return cnt;
    } 
    
    Choice 5

    Code:
    int count_digits (const char * buf) {
      assert(buf != NULL);
      int cnt = 0;
      for (int i = 0; buf[i] != '\0'; i++)
        if (isdigit(buf[i]))
          cnt++;
      return cnt;
    } 
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 35*/
    struct employee *ptr = malloc( sizeof( struct employee ) );
    Given the sample allocation for the pointer "ptr" found above, which one of the following statements is used to reallocate ptr to be an array of 5 elements?
    Choice 1
    ptr = realloc( ptr, 5 * sizeof( struct employee)); [Ans]
    Choice 2
    realloc( ptr, 4 * sizeof( struct employee ) );
    Choice 3
    ptr += malloc( 4 * sizeof( struct employee ) );
    Choice 4
    ptr = realloc( ptr, 4 * sizeof( struct employee ) );
    Choice 5
    realloc( ptr, 5 * sizeof( struct employee ) );
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 36*/
    Which is true statement about pointers?
    Choice 1
    Pointer arithmetic is permitted on any type of pointers.
    Choice 2
    A void * pointer can be used to directly examine or modify an object of any type.
    Choice 3
    Standard C mandates minimum four levels of indirection accessible via a pointer.
    Choice 4
    A C program knows pointer type and references data at runtime.
    Choice 5
    Pointers can simulate call-by-reference.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 37*/
    Which function will return string from a pointer of time_t value?
    Choice 1
    localtime
    Choice 2
    gmtime
    Choice 3
    strtime
    Choice 4
    asctime
    Choice 5
    ctime
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 38*/
    Code:
    short testarray[4][3] = { {1}, {2, 3}, {4, 5, 6} };
    printf( "%d\n", sizeof( testarray ) ); 
    
    Assuming a short is two bytes long, what will be printed by the above code?
    Choice 1
    It will not compile because not enough initializers are given.
    Choice 2
    6
    Choice 3
    7
    Choice 4
    12
    Choice 5
    24 [Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 39*/
    char buf [] = "Hello world!";

    char * buf = "Hello world!";
    In terms of code generation, how do the two definitions of buf, both presented above, differ?
    Choice 1
    The first definition certainly allows the contents of buf to be safely modified at runtime; the second definition does not.
    Choice 2
    The first definition is not suitable for usage as an argument to a function call; the second definition is.
    Choice 3
    The first definition is not legal because it does not indicate the size of the array to be allocated; the second definition is legal.
    Choice 4
    They do not differ -- they are functionally equivalent. [Ans]
    Choice 5
    The first definition does not allocate enough space for a terminating NUL-character, nor does it append one; the second definition does.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 40*/
    In C Programming, How to represent a logical AND?
    Choice 1
    @@
    Choice 2
    ||
    Choice 3
    .AND.
    Choice 4
    && [Ans]
    Choice 5
    .AND
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 41*/
    How do printf()'s treat %e and %f differently for floating-point numbers?
    Choice 1
    %f always displays an argument of type double in decimal notation; %e always displays the argument of type double in engineering notation; [Ans]
    Choice 2
    %e expects argument of type double; %f expects argument of type float.
    Choice 3
    %e displays a double in engineering notation if the number is very small or very large. Otherwise, it behaves like %f and displays the number in decimal notation.
    Choice 4
    %e displays an argument of type double with trailing zeros; %f never displays trailing zeros.
    Choice 5
    %e and %f both expect a corresponding argument of type double and format it identically. %e is left over from K&R C; Standard C prefers %f for new code.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 42*/
    Which function can reset end-of-file and error conditions on an open stream?
    Choice 1
    clearerr()
    Choice 2
    fseek()
    Choice 3
    ferror()
    Choice 4
    feof()
    Choice 5
    setvbuf()
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 43*/
    Which one of the following will read a character from the keyboard and will store it in the variable c?
    Choice 1
    c = getc();
    Choice 2
    getc( &c );
    Choice 3
    c = getchar( stdin );
    Choice 4
    getchar( &c )
    Choice 5
    c = getchar(); [Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 44*/
    Code:
    #include <stdio.h>
    int i;
    void increment( int i )
    {
       i++;
    }
    
    int main()
    {
       for( i = 0; i < 10; increment( i ) )
       {
       }
       printf("i=%d\n", i);
       return 0;
    } 
    
    What will happen when the program above is compiled and executed?
    Choice 1
    It will not compile.
    Choice 2
    It will print out: i=9.
    Choice 3
    It will print out: i=10.
    Choice 4
    It will print out: i=11.
    Choice 5
    It will loop indefinitely.[Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 45*/
    Code:
    char ptr1[] = "Hello World";
    char *ptr2 = malloc( 5 );
    ptr2 = ptr1; 
    
    What is wrong with the above code (assuming the call to malloc does not fail)?
    Choice 1
    There will be a memory overwrite.
    Choice 2
    There will be a memory leak.
    Choice 3
    There will be a segmentation fault.
    Choice 4
    Not enough space is allocated by the malloc.
    Choice 5
    It will not compile.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 46*/
    Code:
    int i = 4;
    switch (i)
    {
       default:
          ;
       case 3:
          i += 5;
          if ( i == 8)
          {
             i++;
             if (i == 9) break;
             i *= 2;
          }
          i -= 4;
          break;
       case 8:
          i += 5;
          break;
    }
    printf("i = %d\n", i); 
    
    What will the output of the sample code above be?
    Choice 1
    i = 5[Ans]
    Choice 2
    i = 8
    Choice 3
    i = 9
    Choice 4
    i = 10
    Choice 5
    i = 18
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 47*/
    Which one is a right associative C operator?
    Choice 1
    = [Ans]
    Choice 2
    ,
    Choice 3
    []
    Choice 4
    ^
    Choice 5
    ->
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 48*/
    What does the "auto" specifier do?
    Choice 1
    It automatically initializes a variable to 0;.
    Choice 2
    It indicates that a variable's memory will automatically be preserved.[Ans]
    Choice 3
    It automatically increments the variable when used.
    Choice 4
    It automatically initializes a variable to NULL.
    Choice 5
    It indicates that a variable's memory space is allocated upon entry into the block.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 49*/
    How can one include a system header file called sysheader.h in C?
    Choice 1
    #include <sysheader.h> [Ans]
    Choice 2
    #include "sysheader.h"
    Choice 3
    #include 'sysheader'
    Choice 4
    #include sysheader.h
    Choice 5
    #inc <sysheader.h>

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 50*/
    Which one of the following printf() format specifiers indicates to print a double value in decimal notation, left aligned in a 30-character field, to four (4) digits of precision?
    Choice 1
    %-30.4e
    Choice 2
    %4.30e
    Choice 3
    %-4.30f
    Choice 4
    %-30.4f [Ans] decimal notation
    Choice 5
    %#30.4f
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 51*/
    Code:
    int x = 0;
    for ( ; ; )
    {
    if (x++ == 4)
      break;
    continue;
    }
    printf("x=%d\n", x); 
    
    What will be printed when the sample code above is executed?
    Choice 1
    x=0
    Choice 2
    x=1
    Choice 3
    x=4
    Choice 4
    x=5[Ans]
    Choice 5
    x=6
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 52*/
    According to the Standard C specification, what are the respective minimum sizes (in bytes) of the following three data types: short; int; and long?
    Choice 1
    1, 2, 2
    Choice 2
    1, 2, 4
    Choice 3
    1, 2, 8
    Choice 4
    2, 2, 4[Ans]
    Choice 5
    2, 4, 8
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 53*/
    Code:
    int y[4] = {6, 7, 8, 9};
    int *ptr = y + 2;
    printf("%d\n", ptr[ 1 ] );  /*ptr+1 == ptr[1]*/
    
    What is printed when the sample code above is executed?
    Choice 1
    6
    Choice 2
    7
    Choice 3
    8
    Choice 4
    9[Ans]
    Choice 5
    The code will not compile.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 54*/
    penny = one
    nickel = five
    dime = ten
    quarter = twenty-five
    How is enum used to define the values of the American coins listed above?
    Choice 1
    enum coin {(penny,1), (nickel,5), (dime,10), (quarter,25)};
    Choice 2
    enum coin ({penny,1}, {nickel,5}, {dime,10}, {quarter,25});
    Choice 3
    enum coin {penny=1,nickel=5,dime=10,quarter=25};[Ans]
    Choice 4
    enum coin (penny=1,nickel=5,dime=10,quarter=25);
    Choice 5
    enum coin {penny, nickel, dime, quarter} (1, 5, 10, 25);
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 55*/
    char txt [20] = "Hello world!\0";
    How many bytes are allocated by the definition above?
    Choice 1
    11 bytes
    Choice 2
    12 bytes
    Choice 3
    13 bytes
    Choice 4
    20 bytes[Ans]
    Choice 5
    21 bytes
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 56*/
    Code:
    int i = 4;
    int x = 6;
    double z;
    z =  x / i;
    printf("z=%.2f\n", z); 
    
    What will print when the sample code above is executed?
    Choice 1
    z=0.00
    Choice 2
    z=1.00[Ans]
    Choice 3
    z=1.50
    Choice 4
    z=2.00
    Choice 5
    z=NULL
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 57*/
    Which one of the following variable names is NOT valid?
    Choice 1
    go_cart
    Choice 2
    go4it
    Choice 3
    4season[Ans]
    Choice 4
    run4
    Choice 5
    _what
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 58*/
    int a [8] = { 0, 1, 2, 3 };
    The definition of a above explicitly initializes its first four elements. Which one of the following describes how the compiler treats the remaining four elements?
    Choice 1
    Standard C defines this particular behavior as implementation-dependent. The compiler writer has the freedom to decide how the remaining elements will be handled.
    Choice 2
    The remaining elements are initialized to zero(0).[Ans]
    Choice 3
    It is illegal to initialize only a portion of the array. Either the entire array must be initialized, or no part of it may be initialized.
    Choice 4
    As with an enum, the compiler assigns values to the remaining elements by counting up from the last explicitly initialized element. The final four elements will acquire the values 4, 5, 6, and 7, respectively.
    Choice 5
    They are left in an uninitialized state; their values cannot be relied upon.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 59*/
    Which one of the following is a true statement about pointers?
    Choice 1
    They are always 32-bit values.
    Choice 2
    For efficiency, pointer values are always stored in machine registers.
    Choice 3
    With the exception of generic pointers, similarly typed pointers may be subtracted from each other.
    Choice 4
    A pointer to one type may not be cast to a pointer to any other type.
    Choice 5
    With the exception of generic pointers, similarly typed pointers may be added to each other.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 60*/
    Which one of the following statements allocates enough space to hold an array of 10 integers that are initialized to 0?
    Choice 1
    int *ptr = (int *) malloc(10, sizeof(int));
    Choice 2
    int *ptr = (int *) calloc(10, sizeof(int));
    Choice 3
    int *ptr = (int *) malloc(10*sizeof(int)); [Ans]
    Choice 4
    int *ptr = (int *) alloc(10*sizeof(int));
    Choice 5
    int *ptr = (int *) calloc(10*sizeof(int));
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 61*/
    What are two predefined FILE pointers in C?
    Choice 1
    stdout and stderr
    Choice 2
    console and error
    Choice 3
    stdout and stdio
    Choice 4
    stdio and stderr
    Choice 5
    errout and conout
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 62*/
    Code:
    u32 X (f32 f)
    {
    union {
            f32 f;
            u32 n;
           } u;
    u.f = f;
    return u.n;
    }
    
    Given the function X(), defined above, assume that u32 is a type-definition indicative of a 32-bit unsigned integer and that f32 is a type-definition indicative of a 32-bit floating-point number.
    Which one of the following describes the purpose of the function defined above?
    Choice 1
    X() effectively rounds f to the nearest integer value, which it returns.
    Choice 2
    X() effectively performs a standard typecast and converts f to a roughly equivalent integer.
    Choice 3
    X() preserves the bit-pattern of f, which it returns as an unsigned integer of equal size.
    Choice 4
    Since u.n is never initialized, X() returns an undefined value. This function is therefore a primitive pseudorandom number generator.
    Choice 5
    Since u.n is automatically initialized to zero (0) by the compiler, X() is an obtuse way of always obtaining a zero (0) value.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 63*/
    Code:
    long factorial (long x)
    {
    ????
    return x * factorial(x - 1);
    } 
    
    With what do you replace the ???? to make the function shown above return the correct answer?
    Choice 1
    if (x == 0) return 0;
    Choice 2
    return 1;
    Choice 3
    if (x >= 2) return 2;
    Choice 4
    if (x == 0) return 1;
    Choice 5
    if (x <= 1) return 1; [Ans]{more probable}
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 64*/
    Code:
    /* Increment each integer in the array 'p' of * size 'n'. */
    void increment_ints (int p [/*n*/], int n)
    {
      assert(p != NULL);  /* Ensure that 'p' isn't a null pointer. */
      assert(n >= 0);  /* Ensure that 'n' is nonnegative. */
      while (n)  /* Loop over 'n' elements of 'p'. */
      {
        *p++;          /* Increment *p. */
        p++, n--;      /* Increment p, decrement n. */
      }
    } 
    
    Consider the function increment_ints(), defined above. Despite its significant inline commentary, it contains an error. Which one of the following correctly assesses it?
    Choice 1
    *p++ causes p to be incremented before the dereference is performed, because both operators have equal precedence and are right associative.
    Choice 2
    An array is a nonmodifiable lvalue, so p cannot be incremented directly. A navigation pointer should be used in conjunction with p.
    Choice 3
    *p++ causes p to be incremented before the dereference is performed, because the autoincrement operator has higher precedence than the indirection operator.
    Choice 4
    The condition of a while loop must be a Boolean expression. The condition should be n != 0.
    Choice 5
    An array cannot be initialized to a variable size. The subscript n should be removed from the definition of the parameter p.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 65*/
    How is a variable accessed from another file?
    Choice 1
    The global variable is referenced via the extern specifier.[Ans]
    Choice 2
    The global variable is referenced via the auto specifier.
    Choice 3
    The global variable is referenced via the global specifier.
    Choice 4
    The global variable is referenced via the pointer specifier.
    Choice 5
    The global variable is referenced via the ext specifier.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 66*/
    When applied to a variable, what does the unary "&" operator yield?
    Choice 1
    The variable's value
    Choice 2
    The variable's binary form
    Choice 3
    The variable's address [Ans]
    Choice 4
    The variable's format
    Choice 5
    The variable's right value
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 67*/
    Code:
    /* sys/cdef.h */
    #if     defined(__STDC__) || defined(__cplusplus)
    #define __P(protos)   protos
    #else
    #define __P(protos)   ()
    #endif
    /* stdio.h */
    #include <sys/cdefs.h>
    div_t div __P((int, int)); 
    
    The code above comes from header files for the FreeBSD implementation of the C library. What is the primary purpose of the __P() macro?
    Choice 1
    The __P() macro has no function, and merely obfuscates library function declarations. It should be removed from further releases of the C library.
    Choice 2
    The __P() macro provides forward compatibility for C++ compilers, which do not recognize Standard C prototypes.
    Choice 3
    Identifiers that begin with two underscores are reserved for C library implementations. It is impossible to determine the purpose of the macro from the context given.
    Choice 4
    The __P() macro provides backward compatibility for K&R C compilers, which do not recognize Standard C prototypes.
    Choice 5
    The __P() macro serves primarily to differentiate library functions from application-specific functions.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 68*/
    Which one of the following is NOT a valid identifier?
    Choice 1
    __ident
    Choice 2
    auto [Ans]
    Choice 3
    bigNumber
    Choice 4
    g42277
    Choice 5
    peaceful_in_space
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 69*/
    /* Read an arbitrarily long string. */
    Code:
    int read_long_string (const char ** const buf) {
      char * p = NULL;
      const char * fwd = NULL;
      size_t len = 0;
      assert(buf);
      do
      {
       p = realloc(p, len += 256);
       if (!p)
        return 0;
       if (!fwd)
        fwd = p;
       else
        fwd = strchr(p, '\0');
      } while (fgets(fwd, 256, stdin));
      *buf = p;
      return 1;
    } 
    
    The function read_long_string(), defined above, contains an error that may be particularly visible under heavy stress. Which one of the following describes it?
    Choice 1
    The write to *buf is blocked by the const qualifications applied to its type.
    Choice 2
    If the null pointer for char is not zero-valued on the host machine, the implicit comparisons to zero (0) may introduce undesired behavior. Moreover, even if successful, it introduces machine-dependent behavior and harms portability.
    Choice 3
    The symbol stdin may not be defined on some ANCI C compliant systems.
    Choice 4
    The else causes fwd to contain an errant address.
    Choice 5
    If the call to realloc() fails during any iteration but the first, all memory previously allocated by the loop is leaked.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 70*/
    Code:
    FILE *f = fopen( fileName, "r" );
    readData( f );
    if( ???? )
    {
    puts( "End of file was reached" );
    } 
    
    Which one of the following can replace the ???? in the code above to determine if the end of a file has been reached?
    Choice 1
    f == EOF[Ans]
    Choice 2
    feof( f )
    Choice 3
    eof( f )
    Choice 4
    f == NULL
    Choice 5
    !f
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 71*/
    Global variables that are declared static are ____________.
    Which one of the following correctly completes the sentence above?
    Choice 1
    Deprecated by Standard C
    Choice 2
    Internal to the current translation unit
    Choice 3
    Visible to all translation units
    Choice 4
    Read-only subsequent to initialization
    Choice 5
    Allocated on the heap[Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 72*/
    /* Read a double value from fp. */
    Code:
    double read_double (FILE * fp) {
      double d;
      assert(fp != NULL);
      fscanf(fp, " %lf", d);
      return d;
    } 
    
    The code above contains a common error. Which one of the following describes it?
    Choice 1
    fscanf() will fail to match floating-point numbers not preceded by whitespace.
    Choice 2
    The format specifier %lf indicates that the corresponding argument should be long double rather than double.
    Choice 3
    The call to fscanf() requires a pointer as its last argument.
    Choice 4
    The format specifier %lf is recognized by fprintf() but not by fscanf().
    Choice 5
    d must be initialized prior to usage.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 73*/
    Which one of the following is NOT a valid C identifier?
    Choice 1
    ___S
    Choice 2
    1___ [Ans]
    Choice 3
    ___1
    Choice 4
    ___
    Choice 5
    S___
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 74*/
    According to Standard C, what is the type of an unsuffixed floating-point literal, such as 123.45?
    Choice 1
    long double
    Choice 2
    Unspecified
    Choice 3
    float[Ans]
    Choice 4
    double
    Choice 5
    signed float
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 75*/
    Which one of the following is true for identifiers that begin with an underscore?
    Choice 1
    They are generally treated differently by preprocessors and compilers from other identifiers.
    Choice 2
    They are case-insensitive.
    Choice 3
    They are reserved for usage by standards committees, system implementers, and compiler engineers.
    Choice 4
    Applications programmers are encouraged to employ them in their own code in order to mark certain symbols for internal usage. Choice 5
    They are deprecated by Standard C and are permitted only for backward compatibility with older C libraries.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 76*/
    Which one of the following is valid for opening a read-only ASCII file? Choice 1
    fileOpen (filenm, "r");
    Choice 2
    fileOpen (filenm, "ra");
    Choice 3
    fileOpen (filenm, "read");
    Choice 4
    fopen (filenm, "read");
    Choice 5
    fopen (filenm, "r");[Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 77*/
    f = fopen( filename, "r" );
    Referring to the code above, what is the proper definition for the variable f?
    Choice 1
    FILE f;
    Choice 2
    FILE *f;[Ans]
    Choice 3
    int f;
    Choice 4
    struct FILE f;
    Choice 5
    char *f;
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 78*/
    If there is a need to see output as soon as possible, what function will force the output from the buffer into the output stream?
    Choice 1
    flush()
    Choice 2
    output()
    Choice 3
    fflush()
    Choice 4
    dump()
    Choice 5
    write()
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 79*/
    short int x; /* assume x is 16 bits in size */
    What is the maximum number that can be printed using printf("%d\n", x), assuming that x is initialized as shown above?
    Choice 1
    127
    Choice 2
    128
    Choice 3
    255
    Choice 4
    32,767 [Ans]
    Choice 5
    65,536
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 80*/
    Code:
    void func(void)
    {
        printf("func");
        ((char*) 0)=0;
    }
    
    The function func(), triggers memory fault. Which one explains why "func" may NOT be printed before the crash?

    Choice 1
    Insufficient information to determine why the output fails.
    Choice 2
    printf() expects more than one argument. As only one argument is given, crash may actually occur inside printf().
    Choice 3
    Output stream is buffered and may not be flushed before the crash occurs.
    Choice 4
    printf() always buffers output until a newline character appears in buffer. Since no newline was present in the format string, nothing is printed.
    Choice 5
    printf() expects more than a single argument. Since only one argument is given, the crash may actually occur inside printf(), which explains why the string is not printed. puts() should be used instead.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 81*/
    Code:
    char * dwarves [] = {
      "Sleepy",
      "Dopey" "Doc",
      "Happy",
      "Grumpy" "Sneezy",
      "Bashful",
    }; 
    
    How many elements does the array dwarves (declared above) contain? Assume the C compiler employed strictly complies with the requirements of Standard C.
    Choice 1
    4
    Choice 2
    5[Ans]
    Choice 3
    6
    Choice 4
    7
    Choice 5
    8
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 82*/
    Which one of the following can be used to test arrays of primitive quantities for strict equality under Standard C?
    Choice 1
    qsort()
    Choice 2
    bcmp()
    Choice 3
    memcmp()
    Choice 4
    strxfrm()
    Choice 5
    bsearch()
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 83*/
    Code:
    int debug (const char * fmt, ...) {
      extern FILE * logfile;
      va_list args;
      assert(fmt);
      args = va_arg(fmt, va_list);
      return vfprintf(logfile, fmt, args);
    } 
    
    The function debug(), defined above, contains an error. Which one of the following describes it?
    Choice 1
    The ellipsis is a throwback from K&R C. In accordance with Standard C, the declaration of args should be moved into the parameter list, and the K&R C macro va_arg() should be deleted from the code.
    Choice 2
    vfprintf() does not conform to ISO 9899: 1990, and may not be portable.
    Choice 3
    Library routines that accept argument lists cause a fault on receipt of an empty list. The argument list must be validated with va_null() before invoking vfprintf().
    Choice 4
    The argument list args has been improperly initialized.
    Choice 5
    Variadic functions are discontinued by Standard C; they are legacy constructs from K&R C, and no longer compile under modern compilers.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 84*/
    Code:
    char *buffer = "0123456789";
    char *ptr = buffer;
    ptr += 5;
    printf( "%s\n", ptr );
    printf( "%s\n", buffer ); 
    
    What will be printed when the sample code above is executed?
    Choice 1
    0123456789
    56789
    Choice 2
    5123456789
    5123456789
    Choice 3
    56789
    56789
    Choice 4
    0123456789
    0123456789
    Choice 5
    56789
    0123456789 [Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 85*/
    /* Get the rightmost path element of a Unix path. */
    Code:
    char * get_rightmost (const char * d)
    {
    char rightmost [MAXPATHLEN];
    const char * p = d;
    assert(d != NULL);
    while (*d != '\0')
    {
      if (*d == '/')
       p = (*(d + 1) != '\0') ? d + 1 : p;
      d++;
    }
    memset(rightmost, 0, sizeof(rightmost));
    memcpy(rightmost, p, strlen(p) + 1);
    return rightmost;
    } 
    
    The function get_rightmost(), defined above, contains an error. Which one of the following describes it?
    Choice 1
    The calls to memset() and memcpy() illegally perform a pointer conversion on rightmost without an appropriate cast.
    Choice 2
    The code does not correctly handle the situation where a directory separator '/' is the final character.
    Choice 3
    The if condition contains an incorrectly terminated character literal.
    Choice 4
    memcpy() cannot be used safely to copy string data.
    Choice 5
    The return value of get_rightmost() will be invalid in the caller's context.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 86*/
    What number is equivalent to -4e3?
    Choice 1
    -4000 [Ans]
    Choice 2
    -400
    Choice 3
    -40
    Choice 4
    .004
    Choice 5
    .0004
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 87*/
    Code:
    void freeList( struct node *n )
    {
    while( n )
    {
      ????
    }
    } 
    
    Which one of the following can replace the ???? for the function above to release the memory allocated to a linked list?
    Choice 1
    n = n->next;
    free( n );
    Choice 2
    struct node m = n;
    n = n->next;
    free( m );
    Choice 3
    struct node m = n;
    free( n );
    n = m->next;
    Choice 4
    free( n );
    n = n->next;
    Choice 5
    struct node m = n;
    free( m );
    n = n->next;
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 88*/
    How does variable definition differ from variable declaration?
    Choice 1
    Definition allocates storage for a variable, but declaration only informs the compiler as to the variable's type.
    Choice 2
    Declaration allocates storage for a variable, but definition only informs the compiler as to the variable's type.
    Choice 3
    Variables may be defined many times, but may be declared only once.[Ans]
    Choice 4
    Variable definition must precede variable declaration.
    Choice 5
    There is no difference in C between variable declaration and variable definition.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 89*/
    Code:
    int x[] = {1, 2, 3, 4, 5};
    int u;
    int *ptr = x;
    ????
    for( u = 0; u < 5; u++ )
    {
    printf("%d-", x[u]);
    }
    
    printf( "\n" );
    Which one of the following statements could replace the ???? in the code above to cause the string 1-2-3-10-5- to be printed when the code is executed?
    Choice 1
    *ptr + 3 = 10;
    Choice 2
    *ptr[ 3 ] = 10;
    Choice 3
    *(ptr + 3) = 10;[Ans]
    Choice 4
    (*ptr)[ 3 ] = 10;
    Choice 5
    *(ptr[ 3 ]) = 10;
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 90*/
    Code:
    /*sum_array() has been ported from FORTRAN. No * logical changes have been made*/
    double sum_array(double d[],int n)
    {
    register int i;
    double total=0;
    assert(d!=NULL);
    for(i=l;i<=n;i++)
      total+=d[i];
    return total;
    }
    
    The function sum_array(), defined above, contains an error. Which one of the following accurately describes it?
    Choice 1
    The range of the loop does not match the bounds of the array d.
    Choice 2
    The loop processes the incorrect number of elements.
    Choice 3
    total is initialized with an integer literal. The two are not compatible in an assignment.
    Choice 4
    The code above fails to compile if there are no registers available for i.
    Choice 5
    The formal parameter d should be declared as double * d to allow dynamically allocated arrays as arguments.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 91*/
    Code:
    #include <stdio.h>
    void func()
    {
       int x = 0;
       static int y = 0;
       x++; y++;
       printf( "%d -- %d\n", x, y );
    }
    
    int main()
    {
       func();
       func();
       return 0;
    } 
    
    What will the code above print when it is executed?
    Choice 1
    1 -- 1
    1 -- 1
    Choice 2
    1 -- 1
    2 -- 1
    Choice 3
    1 -- 1
    2 -- 2
    Choice 4
    1 -- 0
    1 -- 0
    Choice 5
    1 -- 1
    1 -- 2 [Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 92*/ $$No other seems that sound$$
    Code:
    int fibonacci (int n)
    {
    switch (n)
    {
      default:
          return (fibonacci(n - 1) + fibonacci(n - 2));
      case 1:
      case 2:
    }
      return 1;
    } 
    
    The function above has a flaw that may result in a serious error during some invocations. Which one of the following describes the deficiency illustrated above?
    Choice 1
    For some values of n, the environment will almost certainly exhaust its stack space before the calculation completes.
    [Ans]
    Choice 2
    An error in the algorithm causes unbounded recursion for all values of n.
    Choice 3
    A break statement should be inserted after each case. Fall-through is not desirable here.
    Choice 4
    The fibonacci() function includes calls to itself. This is not directly supported by Standard C due to its unreliability.
    Choice 5
    Since the default case is given first, it will be executed before any case matching n.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 93*/
    When applied to a variable, what does the unary "&" operator yield?
    Choice 1
    The variable's address [Ans]
    Choice 2
    The variable's right value
    Choice 3
    The variable's binary form
    Choice 4
    The variable's value
    Choice 5
    The variable's format
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 94*/
    short int x; /* assume x is 16 bits in size */
    What is the maximum number that can be printed using printf("%d\n", x), assuming that x is initialized as shown above?
    Choice 1
    127
    Choice 2
    128
    Choice 3
    255
    Choice 4
    32,767[Ans]
    Choice 5
    65,536
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 95*/
    int x = 011 | 0x10;
    What value will x contain in the sample code above?
    Choice 1
    3
    Choice 2
    13
    Choice 3
    19
    Choice 4
    25
    Choice 5
    27
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 96*/
    Which one of the following calls will open the file test.txt for reading by fgetc?
    Choice 1
    fopen( "test.txt", "r" );
    Choice 2
    read( "test.txt" )
    Choice 3
    fileopen( "test.txt", "r" );
    Choice 4
    fread( "test.txt" )
    Choice 5
    freopen( "test.txt" )
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 97*/
    Code:
    int m = -14;
    int n = 6;
    int o;
    o = m % ++n;
    n += m++ - o;
    m <<= (o ^ n) & 3; 
    
    Assuming two's-complement arithmetic, which one of the following correctly represents the values of m, n, and o after the execution of the code above?
    Choice 1
    m = -26, n = -7, o = 0
    Choice 2
    m = -52, n = -4, o = -2
    Choice 3
    m = -26, n = -5, o = -2
    Choice 4
    m = -104, n = -7, o = 0
    Choice 5
    m = -52, n = -6, o = 0
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 98*/
    How do printf()'s format specifiers %e and %f differ in their treatment of floating-point numbers?
    Choice 1
    %e displays an argument of type double with trailing zeros; %f never displays trailing zeros.
    Choice 2
    %e displays a double in engineering notation if the number is very small or very large. Otherwise, it behaves like %f and displays the number in decimal notation.
    Choice 3
    %e always displays an argument of type double in engineering notation; %f always displays an argument of type double in decimal notation. [Ans]
    Choice 4
    %e expects a corresponding argument of type double; %f expects a corresponding argument of type float.
    Choice 5
    %e and %f both expect a corresponding argument of type double and format it identically. %e is left over from K&R C; Standard C prefers %f for new code.
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 99*/ $$Except 1 all choices are O.K.$$
    c = getchar();
    What is the proper declaration for the variable c in the code above?
    Choice 1
    char *c;
    Choice 2
    unsigned int c;
    Choice 3
    int c;
    Choice 4
    unsigned char c;
    Choice 5
    char c;[Ans]
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    /*question number 100*/
    Which one of the following will define a function that CANNOT be called from another source file?
    Choice 1
    void function() { ... }
    Choice 2
    extern void function() { ... }
    Choice 3
    const void function() { ... }
    Choice 4
    private void function() { ... }
    Choice 5
    static void function() { ... }
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     
    Last edited by a moderator: Feb 6, 2017
    shabbir, ManzZup and izen like this.
  2. uma

    uma New Member

    Joined:
    Jan 31, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    how to send the answers?
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I would suggest dont keep them here because that would be the spoiler. Put them in a seperate thread and place a link from here if you wish to.
     
  4. chaudhary.4all

    chaudhary.4all New Member

    Joined:
    Feb 27, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    plz attach the answer
    i need them
     
  5. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    That would be the spoiler.
     
  6. chaudhary.4all

    chaudhary.4all New Member

    Joined:
    Feb 27, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
  7. milashf

    milashf New Member

    Joined:
    Mar 19, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    plz i need the ans for these que for our collg prgm. it would be very helpful if i can get today itself
    my id is milashm@gmail.com i will help u in way i can when u need help
     
  8. wrecker

    wrecker New Member

    Joined:
    Mar 12, 2007
    Messages:
    40
    Likes Received:
    0
    Trophy Points:
    0
    Are the choices marked [Ans], correct answers or you think it to be correct. I dont find every one correct......
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    It looks correct to me though.
     
  10. Dark_Knight

    Dark_Knight New Member

    Joined:
    Apr 6, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I guess the answers are already there to many questions.
     
  12. Dark_Knight

    Dark_Knight New Member

    Joined:
    Apr 6, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    There are quite a few question which I dont know how to solve, so I needed answers for those
     
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    You can always discuss them in the forums (Unless you get the answers.)
     
  14. Dark_Knight

    Dark_Knight New Member

    Joined:
    Apr 6, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    How do u solve this?

    /*question number 97*/

    Code:

    int m = -14;
    int n = 6;
    int o;
    o = m % ++n;
    n += m++ - o;
    m <<= (o ^ n) & 3;
    Assuming two's-complement arithmetic, which one of the following correctly represents the values of m, n, and o after the execution of the code above?
    Choice 1
    m = -26, n = -7, o = 0
    Choice 2
    m = -52, n = -4, o = -2
    Choice 3
    m = -26, n = -5, o = -2
    Choice 4
    m = -104, n = -7, o = 0
    Choice 5
    m = -52, n = -6, o = 0
     
  15. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    o = -14 % 7 = 0
    n = 7 + (-14) - 0 = -7 which concludes the result.
     
  16. Dark_Knight

    Dark_Knight New Member

    Joined:
    Apr 6, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
  17. Dark_Knight

    Dark_Knight New Member

    Joined:
    Apr 6, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    *question number 75*/
    Which one of the following is true for identifiers that begin with an underscore?
    Choice 1
    They are generally treated differently by preprocessors and compilers from other identifiers.
    Choice 2
    They are case-insensitive.
    Choice 3
    They are reserved for usage by standards committees, system implementers, and compiler engineers.
    Choice 4
    Applications programmers are encouraged to employ them in their own code in order to mark certain symbols for internal usage. Choice 5
    They are deprecated by Standard C and are permitted only for backward compatibility with older C libraries.


    Is the answer (1) ?
     
  18. Dark_Knight

    Dark_Knight New Member

    Joined:
    Apr 6, 2007
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    Sorry, I think its 4
     
  19. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    :rolleyes:
     
  20. AHMAD

    AHMAD New Member

    Joined:
    Jun 12, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    How Are You
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice