Sunday, September 13, 2015

Placement papers of Sasken 2015.

Placement papers of Sasken 2015.

Sasken Placement Papers - Interview Questions:

1. main()
    {
        int a = 10,*j;
        void *k;
        j = k =&a;
        j++;
        k++;
        printf("\n %u %u",j,k);
    }
   

    A.compiler error            B.syntax error            C.memory address            D.noo out put

    Answer: A

    Explanation:
    cannot increment a void pointer

2. What will be the output of the program?
    #include
    int i;
    int fun1(int);
    int fun2(int);
    int main()
    {
        extern int j;
        int i=3;
        fun1(i);
        printf("%d,", i);
        fun2(i);
        printf("%d", i);
        return 0;
    }
    int fun1(int j)
    {
        printf("%d,", ++j);
        return 0;
    }
    int fun2(int i)
    {
        printf("%d,", ++i);
        return 0;
    }
    int j=1;

   
    A.3, 4, 4, 3            B.4, 3, 4, 3            C.3, 3, 4, 4            D.3, 4, 3, 4

    Answer: B

3. main()
{
    int i =3;
    for(; i ++ = 0;)
    printf("%d",i);
}

   
    A.compiler error            B.syntax error            C.some garbage value        D.no out put

    Answer: A

    Explanation:
    Lvalue required in function main

4. Point out the error in the program
    #include
    int main()
    {
        int f(int);
        int b;
        b = f(20);
        printf("%d\n", b);
        return 0;
    }
    int f(int a)
    {
        a > 20? return(10): return(20);
    }

   
    A.Error: Prototype declaration        B.No error        C.Error: return statement cannot be used with conditional operators        D.None of above

    Answer: C

    Explanation:
    In a ternary operator, we cannot use the return statement. The ternary operator requires expressions but not code.

5. What will be output of following c program?

    #define max
    int main()
    {
        printf("%d",max);
        return 0;
    }

   
    A.0            B.null                C.Garbage            D.Compilation error

    Answer: D

6. What will be the output of the program?
    #include
    int i;
    int fun();
    int main()
    {
        while(i)
        {
            fun();
            main();
        }
        printf("Hello\n");
        return 0;
    }
    int fun()
    {
        printf("Hi");
    }

   
    A.Hello            B.Hi Hello                C.No output            D.Infinite loop

    Answer: A

7. What will be output of following c program?
    void main()
    {
        int i;
        for(i=0;i<5;i++)
        {
            int x=0;
            printf("%d",x);
            x++;
        }
    }
   

    A.01234            B.001234            C.0000                D.Infinite loop

    Answer: C

8. What will be the output of the program?
    #include
    int main()
    {
        int x, y, z;
        x=y=z=1;
        z = ++x || ++y && ++z;
        printf("x=%d, y=%d, z=%d\n", x, y, z);
        return 0;
    }

   
    A.x=2, y=1, z=1            B.x=2, y=2, z=1            C.x=2, y=2, z=2            D.error

    Answer: A

9. What will be output of following c program?
    long fu(int);
    char vect[]={1,2,3,4,5};
    void main()
    {
        int i=1; i=fu(++i)+ ++vect[++i]+ ++i+fu(i++);
        printf("%d",i);
    }
    long fu(int x)
    {
        return x*3;
    }
   

    A.31            B.32            C.33            D.34

    Answer: D

10. What will be the output of the program?
    #include
    int main()
    {
        unsigned int i = 65536;
        while(i != 0)
        printf("%d",++i);
        printf("\n");
        return 0;
    }

   
    A.Infinite loop        B.0 1 2 ... 65535            C.0 1 2 ... 32767 - 32766 -32765 -1 0        D.No output

    Answer: D


You can also see: Huawei Placement Papers

11.void main()
    {
        int a = 10, b =20;
        char x = 1, y = 0;
        if(a,b,x,y)
        {
            printf("Freshers World");
        }
    }

What is the output?
   
    A.res is printed            B.freshers world is printed            C.Compiler Error            D.Nothing is printed

    Answer: D

12. What is x in the following program?
    #include int main()
    {
        typedef char (*(*arrfptr[3])())[10];
        arrfptr x;
        return 0;
    }
   

    A.x is a pointer            B.x is an array of three pointer        C.x is an array of three function pointers        D.Error in x declaration

    Answer: C

13. main()
    {
        char throught[2][30] ={ "Don't walk in front of me..",'i am not follow"};
        printf("%c%c,*(thought[0]9),*(*(thought 0)5));
    }
What is the output of this program ?
   

    A.kk        B.int**array2 = (int**)malloc(nrows*sizeof(int*));Don't walk in front of me            C.i may not follow            D.k

    Answer: D

14. What will be the output of the program ?
    #include
    int main()
    {
        int k=1;
        printf("%d == 1 is" "%s\n", k, k==1?"TRUE":"FALSE");
        return 0;
    }

   
    A.k == 1 is TRUE            B.1 == 1 is TRUE            C.1 == 1 is FALSE            D.K == 1 is FALSE

    Answer: B

15. main()
    {
        int i=5;
        printf("%d",i = ++i==6);
    }
   

    A.5            B.1            C.6            D.compiler error

    Answer: B

16. Which files will get closed through the fclose() in the following program?
    #include
    int main()
    {
        FILE *fs, *ft, *fp;
        fp = fopen("A.C", "r");
        fs = fopen("B.C", "r");
        ft = fopen("C.C", "r");
        fclose(fp, fs, ft);
        return 0;
    }

   
    A."A.C" "B.C" "C.C"            B."B.C" "C.C"            C."A.C"            D.Error in fclose()

    Answer: D

17. void main()
    {
        printf("sizeof(void *) = %d \n",sizeof(void*));
        printf("sizeof(int *) = %d \n",sizeof(int*));
        printf("sizeof(double*) = %d \n",sizeof(double*));
        printf("sizeof(struct unknown *) = %d \n",sizeof(struct unknown*));
    }

   
    A.no out put        B.compiler error            C.sizeof(void *) = 2 sizeof(int *) = 2 sizeof(double *) = 2 sizeof(struct unknown *) = 2        D.syntax error

    Answer: C

18. Which of the following statements are correct about the program below?
    #include
    int main()
    {
        int size, i;
        scanf("%d", &size);
        int arr[size];
        for(i=1; i<=size; i++)
        {
            scanf("%d", arr[i]);
            printf("%d", arr[i]);
        }
        return 0;
    }

   
    A.The code is erroneous since the subscript for array used in for loop is in the range 1 to size.   
    B.The code is erroneous since the values of array are getting scanned through the loop.   
    C.The code is erroneous since the statement declaring array is invalid.   
    D.The code is correct and runs successfully.

    Answer: C

19. # include
    char *somefun1()
    {
        char temp[] ="string";
        return temp;
    }
    char * somefun2()
    {
        char temp[] = { 's','t','r','i','n','g'};
        return temp;
    }
    int main()
    {
        puts (somefun1());
        puts(somefun2());
    }
   

    A.syntax error            B.some garbage value            C.compiler error            D.no out put

    Answer: B

20. What will be the output of the program?
    #include
    int fun(int(*)());
    int main()
    {
        fun(main);
        printf("Hi\n");
        return 0;
    }
    int fun(int (*p)())
    {
        printf("Hello ");
        return 0;
    }
   

    A.Infinite loop            B.Hi            C.Hello Hi            D.Error

    Answer: C


You can also see: HP Placement Papers

21. Point out the error, if any in the while loop.
    #include
    int main()
    {
        int i=1;
        while()
        {
            printf("%d\n", i++);
            if(i>10)
            break;
        }
        return 0;
    }

   
    A.There should be a condition in the while loop        B.There should be at least a semicolon in the while        C.The while loop should be replaced with for loop.        D.No error

    Answer: A

22. What will be output of following c program?
    void main()
    {
        int num,a=10;
        num=a--- -a--;
        printf("%d %d",num,a);
    }

   
    A.0 8            B.0 10            C.20 8            D.-1 10

    Answer: C

23. What will be output of following c program?
    float avg(float,float,float);
    void main()
    {
        float p=1,q=2,r=-2,a;
        a=avg(p,(q=4,r=-12,q),r);
        printf("%f",a);
    }
    float avg(float x,float y,float z)
    {
        return (x+y+z)/3;
    }
   

    A.0.111111        B.1.000000            C.-0.777777            D.-1.000000

    Answer: B

24. How many times "Freshersworld" is get printed?
    #include
    int main()
    {
        int x;
        for(x=-1; x<=10; x++)
        {
            if(x < 5)
            continue;
            else break;
            printf("Freshersworld");
        }
        return 0;
     }
   

    A.Infinite times        B.11 times            C.0 times            D.10 times

    Answer: C

25. What will be output of following c program?
    struct myStruct
    {
        int a;
        char b;
    }
    *ptr;
    int main()
    {
        struct myStruct ms={400,'A'};
        printf("%d %d",ptr->a,ptr->b);
        return 0;
    }

   
    A.400 A            B.400 6                C.400 97                D.0 0

    Answer: D

26. What will be the output of the program?
    #include
    int main()
    {
        int i;
        i = scanf("%d %d", &i, &i);
        printf("%d\n", i);
        return 0;
    }

   
    A.1            B.2            C.Garbage value            D.Error: cannot assign scanf to variable

    Answer: B

    Explanation:
    scanf() returns the number of variables to which you are provding the input. i = scanf("%d %d", &i, &i); Here Scanf() returns 2. So i = 2. printf("%d\n", i); Here it prints 2.

27. What will be output of following c program?
    int main()
    {
        float x;
        x=(int)1.1,(float)2.2,(int)3.3 ,5.4;
        printf("%f",x);
        return 0;
    }

   
    A.1.000000        B.5.400000            C.2.200000            D.3.300000

    Answer: A

28. Point out the correct statement which correctly allocates memory dynamically for 2D array following program?
    int main()
    {
        int *p, i, j;
        /* Add statement here */
        for(i=0; i<3; i++)
        {
            for(j=0; j<4; j++)
            {
                p[i*4+j] = i;
                printf("%d", p[i*4+j]);
            }
        }
        return 0;
    }

   
    A.p = (int*) malloc(3, 4);            B.p = (int*) malloc(3*sizeof(int));            C.p = malloc(3*4*sizeof(int));        D.p = (int*) malloc(3*4*sizeof(int));

    Answer: D

29. What will be output if you will compile and execute the following c code?
    void main()
    {
        int i=320;
        char *ptr=(char *)&i;
        printf("%d",*ptr);
    }
   

    A.320            B.1            C.64            D.Compiler error

    Answer: A

30. What will be the output of the program?
    #include
    int main()
    {
        char *s;
        char *fun();
        s = fun();
        printf("%s\n", s);
        return 0;
    }
    char *fun()
    {
        char buffer[30];
        strcpy(buffer, "RAM");
        return (buffer);
    }
   

    A.0xffff            B.Garbage value            C.0xffee            D.Error

    Answer: B

2 comments:

  1. First i would like greet author, thanks for providing valuable information.Good collection.Keep sharing.
    Now all govt jobs in delhi

    ReplyDelete