My Report

C Programming Practice Test 5


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which of the following will stop the loop at the last node of a linked list in the following C code snippet?

    struct node
    {
        struct node *next;
    };

2. What will be the output of the following C code?

    #include <stdio.h>
    struct student
    {
        int no;
        char name[20];
    };
    void main()
    {
        student s;
        s.no = 8;
        printf("hello");
    } 

3. What will be the output of the following C code?

    #include <stdio.h>
    struct student
    {
        char a[5];
    };
    void main()
    {
        struct student s[] = {"hi", "hey"};
        printf("%c", s[0].a[1]);
    } 

4. Which of the following expression is true for the following C statement?

ptr is array with 3 elements of pointer to function returning pointer of int

5. What will be the output of the following C code (run without any command line arguments)?

    #include <stdio.h>
    int main(int argc, char *argv[])
    {
        while (*argv++ != NULL)
        printf("%s\n", *argv);
        return 0;
    } 

6. What will be the output of the following C code?

    #include <stdio.h>
    void (*(f)())(int, float);
    typedef void (*(*x)())(int, float);
    void foo(int i, float f);
    int main()
    {
        x = f;
        x();
    }
    void (*(f)())(int, float)
    {
        return foo;
    }
    void foo(int i, float f)
    {
        printf("%d %f\n", i, f);
    } 

7. What is the advantage of a multidimensional array over pointer array?

8. What will be the output of the following C code?

    #include <stdio.h>
    struct point
    {
        int x;
        int y;
    };
    struct notpoint
    {
        int x;
        int y;
    };
    int main()
    {
        struct point p = {1};
        struct notpoint p1 = p;
        printf("%d\n", p1.x);
    } 

9. Which of the following is not possible in C?

10. Which of the following operation is illegal in structures?


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.