Monday, May 9, 2016

C Important Interview Questions

Int *a[10] refers to

        (a) array of pointers        (b) pointer to an array        (c) pointer to a pointer          (d)        none of these


 Identify the incorrect one from below
                1.if(c=1)
                2.if(c!=3)
                3.if(a
                4.if(c==1)
        (a) 1 only                     (b) 1&3                            (c) 3 only                            (d) All of the above



Regarding the scope of the variables, identify the incorrect statement below:
(a) automatic variables are automatically initialized to 0    (b) static variables are are automatically initialized to 0
(c) the address of a register variable is not accessible       (d) static variables cannot be initialized with any expression



condition 1?condition 2?condition 3?:exp 1:exp 2:exp 3:exp 4;
is equivalent to which of the following?
                (a) if condition 1
                    exp 1;
                    else if condition 2
                    exp 2;
                    else if condition 3
                    exp 3;
                    else exp 4;
                (b) if condition 1
                    if condition 2
                    if condition 3
                    exp 1;
                    else exp 2;
                    else exp 3;
                    else exp 4;
                (c) if condition 1 && condition 2 && condition 3
                    exp 1 |exp 2|exp 3|exp 4;
                (d) if condition 3
                    exp 1;
                    else if condition 2 exp 2;
                    else if condition 3 exp 3;
                    else exp 4;



What is y value of the code, if input x=10
            y=5;
            if (x==10)
            else if(x==9)
            else y=8;
        (a)9                            (b)8                                 (c)6                            (d)7 




Given the piece of code
                int a[50];
                int *pa;
                pa=a;
     To access the 6th element of the array which of the following is incorrect?
     (a) *(a+5)                                (b) a[5]                     (c) pa[5]                           (d) *(*pa + 5) 




Consider the following program
        main()
        {
                unsigned int i=10;
                while(i>=0)
                {
                       printf("%u",i)
                       i--;
                }
       }
    How many times the loop will get executed
    (a)10                                (b)9                                (c)11                                (d) infinite




What is true about the following C Functions
        (a) Need not return any value                   (b) Should always return an integer
        (c) Should always return a float                (d) Should always return more than one value




No comments:

Post a Comment