My Report

C Operators Test – 2


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>
    int main()
    {
        int a = 10, b = 5, c = 5;
        int d;
        d = a == (b + c);
        printf("%d", d);
    } 

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

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

3. What will be the final value of j in the following C code?

    #include <stdio.h>
    int main()
    {
        int i = 10, j = 0;
        if (i || (j = i + 10))
            //do something
            ;
    } 

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

    #include <stdio.h>
    int main()
    {
        int x = 1, y = 0, z = 3;
        x > y ? printf("%d", z) : return z;
    } 

5. Which of the following is not an arithmetic operation?

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

    #include <stdio.h>
    void main()
    {
        int a = 3;
        int b = ++a + a++ + --a;
        printf("Value of b is %d", b);
    } 

7. What will be the final value of j in the following C code?

    #include <stdio.h>
    int main()
    {
        int i = 0, j = 0;
        if (i && (j = i + 10))
            //do something
            ;
    } 

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

    #include <stdio.h>
    int main()
    {
        int a = 10;
        double b = 5.6;
        int c;
        c = a + b;
        printf("%d", c);
    } 

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

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

    #include <stdio.h>
    void main()
    {
        int x = 0, y = 2, z = 3;
        int a = x & y | z;
        printf("%d", a);
    } 

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

    #include <stdio.h>
    int main()
    {
        int i = 1;
        if (i++ && (i == 1))
            printf("Yes\n");
        else
            printf("No\n");
    } 

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

    #include <stdio.h>
    void main()
    {
        int x = 1, y = 0, z = 5;
        int a = x && y && z++;
        printf("%d", z);
    } 

13. What is the precedence of arithmetic operators (from highest to lowest)?

14. Which of the following data type will throw an error on modulus operation(%)?


 

Start practicing “1000 MCQs on C”, and once you are ready, you can take tests on all topics by attempting our “C Test Series”.

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.