Home / General Knowledge / Testing New :: C Fundamentals MCQs

General Knowledge :: Testing New

  1. Determine Output:

    #include<stdio.h>

    void main()

    {

    register i=5;

    char j[]= "hello";

    printf("%s %d", j, i);

    }

  2. A.

     hello 5

    B.

     hello garbage value

    C.

     Error

    D.

     None of These


  3. Determine Output:

    void main()

    {

    int i=5, j=6, z;

    printf("%d", i+++j);

    }

  4. A.

     12

    B.

     13

    C.

     11

    D.

     None of These


  5. Determine Output:

    void main()

    {

    int i = abc(10);

    printf("%d", --i);

    }

    int abc(int i)

    {

    return(i++);

    }

  6. A.

     10

    B.

     9

    C.

     11

    D.

     None of These


  7. Determine Output:

    void main()

    {

    char a[]="12345";

    int i = strlen(a);

    printf("%d", ++i);

    }

  8. A.

     5

    B.

     6

    C.

     7

    D.

     None of These


  9. Determine Output:

    void main()

    {

    int i;

    char a[]="�";

    if(printf("%sn", a))

    printf("Ok here n");

    else

    printf("Forget itn");

    }

  10. A.

     Ok here

    B.

     Forget it

    C.

     Error

    D.

     None of These


  11. Determine Output:

    void main()

    {

    int i=i++, j=j++, k=k++;

    printf("%d %d %d", i, j, k);

    }

  12. A.

     1 1 1

    B.

     0 0 0

    C.

     garbage values

    D.

     Error


  13. Determine Output:

    void main()

    {

    static int i=i++, j=j++, k=k++;

    printf("%d %d %d", i, j, k);

    }

  14. A.

     1 1 1

    B.

     0 0 0

    C.

     garbage values

    D.

     Error


  15. Determine Output:

    #define prod(a,b) a*b

    void main()

    {

    int x=3, y=4;

    printf("%d", prod(x+2, y-1));

    }

  16. A.

     15

    B.

     10

    C.

     12

    D.

     11


  17. Determine Output:

    void main()

    {

    char p[]="%dn";

    p[1] = 'c';

    printf(p, 65);

    }

  18. A.

     65

    B.

     c

    C.

     A

    D.

     Error


  19. Determine Output:

    void main()

    {

    char *p;

    p="%dn";

    p++;

    p++;

    printf(p-2, 300);

    }

  20. A.

     %d\n

    B.

     300

    C.

     Error

    D.

     None of These