My Report

C Programming Practice Test 4


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. What will be the output of the following C code?

    #include <stdio.h>
    void main()
    {
        int k = 5;
        int *p = &k;
        int **m  = &p;
        **m = 6;
        printf("%d\n", k);
    }

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

    #include <stdio.h>
    void main()
    {
        int a[3] = {1, 2, 3};
        int *p = a;
        int *r = &p;
        printf("%d", (**r));
    } 

3. What is the correct syntax to send a 3-dimensional array as a parameter? (Assuming declaration int a[5][4][3];)

4. What is the correct way to declare and assign a function pointer?

(Assuming the function to be assigned is "int multi(int, int);")

5. Arguments that take input by user before running a program are called?

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

    #include <stdio.h>
    #define COLD
    int main()
    {
        #ifdef COLD
        printf("COLD\t");
        #undef COLD
        #endif
        #ifdef COLD
        printf("HOT\t");
        #endif
    }

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

    #include <stdio.h>
    void f(char *k)
    {
        k++;
        k[2] = 'm';
    }
    void main()
    {
        char s[] = "hello";
        f(s);
        printf("%c\n", *s);
    } 

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

    #include <stdio.h>
    void main()
    {
        int k = 5;
        int *p = &k;
        int **m  = &p;
        **m = 6;
        printf("%d\n", k);
    } 

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

    #include <stdio.h>
    void main()
    {
        char *s= "hello";
        char *p = s;
        printf("%c\t%c", *(p + 3),  s[1]);
    } 

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

    #include <stdio.h>
    void main()
    {
        int k = 5;
        int *p = &k;
        int **m  = &p;
        printf("%d%d%d\n", k, *p, **p);
    }

 

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.