Fundamentals of Data Structure MCQ's Set-3

 




1]  The value of eof is

a)      -1

b)      1

c)      0

d)     10

ANSWER : A


2]  Choose correct declaration

a)      int main(intargc,char *argv) {}

b)      int main(intargc,char *argv[]){}

c)      int main(int *argc,char *argv){}

d)     int main(){int *argc,char *argv}

ANSWER : D


3] How to call a function without using the function name to send parameters?

a) typedefs

b) Function pointer

c) Both (a) and (b)

d) None of the mentioned

ANSWER : B


4] Which of the following is the correct syntax to pass a Function Pointer as an argument ?

a) void pass(int (*fptr)(int, float, char)){}

b) void pass(*fptr(int, float, char)){}

c) void pass(int (*fptr)){}

d) void pass(*fptr){}

ANSWER : A


5] Which of the following is not possible in C?

a) Array of function pointer

b) Returning a function pointer

c) Comparison of function pointer

d) None of the mentioned

ANSWER : D


6] What is the output of this C code?

    #include <stdio.h>

    void first()

    {

        printf("Hello World");

    }

    void main()

    {

        void *ptr() = first;

        ptr++

        ptr();

    }


a) Illegal application of ++ to void data type

b) pointer function initialized like a variable

c) Both (a) and (b)

d) None of the mentioned

ANSWER : C


7] Identify invalid expression

a) &274

b) &(a+b)

c) &(a*b)

d) all of the above                                                                 

ANSWER : D


8] Pointers are supported in

a)      C

b)      Fortron

c)     Pascal

d) Both b&c      

ANSWER : D


9] Number of argument use in malloc is

a)      0

b)      1

c)      2

d)   3

ANSWER : A


10] The no. Of argument use in realloc is

a)      0

b)      1

c)      2

d)     3                                            

ANSWER : C


11] The function is use in dynamic deallocation is

a)      Destroy()

b)      Delet()

c)      Free()

d)     Remove()

ANSWER : C                                                            

 

12]  The function call realloc(ptr,0) is

a)      Same as free (ptr)

b)      Used to set the value of ptr to be 0

c)       the value of in the address represented by ptr

d)      Invalid                                                                             

ANSWER : A


13] Pointers can be used to achieve

a)      Call by function

b)      Call by reference

c)      Call by name

d)     Call y procedure      

ANSWER : B                                                   


14]) The declaration of float *a[5] is

a)      An ordinary array

b)      A pointer to an array

c)      An array to an pointer

d)     Pointer to an array                                                  

ANSWER : C


15] The declaration int (*p)[8];

a)      An array of pointer

b)      A pointer to an array

c)      Pointer to function

d)     Function returning pointer                                    

ANSWER : B


16] The oprators used in pointr is

a)      * and /

b)      & and *

c)      & and |

d)     – and >

ANSWER : B


17] Refer the given code snippet 

main()
    {
        int a[5]={-2,-1,3,4,5}
        int *b;
         b=&a[2];
     }

Then value of  b[-1] is:

a)      4

b)      3

c)      -1

d)     -2                                                                                 

ANSWER : C


18] Identify invalid pointer oprator

a)  &

b) >>

c) 

d) None of these                                           

ANSWER : B


19] What is the output of this C code?

    #include <stdio.h>

    int mul(int a, int b, int c)

    {

        return a * b * c;

    }

    void main()

    {

        int (*function_pointer)(int, int, int);

        function_pointer  =  mul;

        printf("The product of three numbers is:%d",

        function_pointer(2, 3, 4));

    }

a) The product of three numbers is:24

b) Run time error

c) Nothing

d) Varies

ANSWER : A


20] What is the output of this C code?

    #include <stdio.h>

    void f(int (*x)(int));

    int myfoo(int);

    int (*fooptr)(int);

    int ((*foo(int)))(int);

    int main()

    {

        fooptr = foo(0);

        fooptr(10);

    }

    int ((*foo(int i)))(int)

    {

        return myfoo;

    }

    int myfoo(int i)

    {

        printf("%d\n", i + 1);

    }

a) 10

b) 11

c) Compile time error

d) Undefined behavior

ANSWER : B




Popular Posts