My Report

C Programming Practice Test 1


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. In the following code snippet, character pointer str holds a reference to the string ___________

char *str =  "Sanfoundry.com\0" "training classes";

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

    #include <stdio.h>
    int main()
    {
        float f1 = 0.1;
        if (f1 == 0.1f)
            printf("equal\n");
        else
            printf("not equal\n");
    }

3. For which of the following, "PI++;" code will fail?

4. Which among the following are the fundamental arithmetic operators, i.e, performing the desired operation can be done using that operator only?

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

    #include <stdio.h>
    void main()
    {
        int x = 4, y, z;
        y = --x;
        z = x--;
        printf("%d%d%d", x, y, z);
    } 

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

    #include <stdio.h>
    void main()
    {
        int const k = 5;
        k++;
        printf("k is %d", k);
    }

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

    #include <stdio.h>
    void main()
    {
        int x = 5.3 % 2;
        printf("Value of x is %d", x);
    } 

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

    #include <stdio.h>
    void main()
    {
        int x = 4;
        int *p = &x;
        int *k = p++;
        int r = p - k;
        printf("%d", r);
    } 

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

    #include <stdio.h>
    int main()
    {
        printf("C programming %s", "Class by\n%s Sanfoundry", "WOW");
    }

10. Which of the following format identifier can never be used for the variable var?

    #include <stdio.h>
    int main()
    {
        char *var = "Advanced Training in C by Sanfoundry.com";
    }

 

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.