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

General Knowledge :: Testing New

  1. Determine Output:

    void main()

    {

    int i;

    printf("%d", scanf("%d", &i)); // value 10 is given as input here

    }

  2. A.

     10

    B.

     1

    C.

     Garbage Value

    D.

     None of These

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Determine Output:

    void main()

    {

    int i=0;

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

    printf("%d", i);

    }

  4. A.

     1

    B.

     11

    C.

     12

    D.

     Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Determine Output:

    void main()

    {

    struct xx

    {

    int x=3;

    char name[] = "hello";

    };

    struct xx *s = malloc(sizeof(struct xx));

    printf("%d", s->x);

    printf("%s", s->name);

    }

  6. A.

     3 hello

    B.

     Compiler Error

    C.

     Linking error

    D.

     None of these

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Determine output:

    void main()

    {

    extern int i;

    i=20;

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

    }

  8. A.

     20

    B.

     2

    C.

     Compiler Error

    D.

     Linker Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Determine Output:

    void main()

    {

    int i=0, j=0;

    if(i && j++)

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

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

    }

  10. A.

     0..1

    B.

     1..0

    C.

     0..0

    D.

     1..1

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Determine Output:

    void main()

    {

    static int i=5;

    if(--i){

    main();

    printf("%d ", i);

    }

    }

  12. A.

     5 4 3 2 1

    B.

     0 0 0 0

    C.

     Infinite Loop

    D.

     None of These

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Determine Output:

    void main()

    {

    int i=-1, j=-1, k=0, l=2, m;

    m = i++ && j++ && k++ || l++;

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

    }

  14. A.

     0 0 1 2 0

    B.

     0 0 1 3 0

    C.

     0 0 1 3 1

    D.

     0 0 0 2 1

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. Determine Output:

    void main()

    {

    int i = -1;

    +i;

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

    }

  16. A.

     i = -1, +i = 1

    B.

     i = 1, +i = 1

    C.

     i = -1, +i = -1

    D.

     None of These

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. Determine Output:

    void main()

    {

    char *str1 = "abcd";

    char str2[] = "abcd";

    printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));

    }

  18. A.

     2 5 5

    B.

     5 5 5

    C.

     2 4 5

    D.

     2 4 4

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. Determine Output:

    void main()

    {

    char not;

    not = !2;

    printf("%d", not);

    }

  20. A.

     2

    B.

     Garbage Value

    C.

     0

    D.

     None of These

    View Answer

    Workspace

    Discuss Discuss in Forum