My Report

C Expression 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. The following C code can be rewritten as _______

c = (n) ? a : b; 

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

    #include <stdio.h>
    void main()
    {
        int k = 8;
        int m = 7;
        k < m ? k++ : m = k;
        printf("%d", k);
    } 

3. What will be the data type of the following expression? (Initial data type: a = int, var1 = double, var2 = float)

expression (a < 50)? var1 : var2;

4. What will be the final values of a and c in the following C statement? (Initial values: a = 2, c = 1)

 c = (c) ? a = 0 : 2;

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

    #include <stdio.h>
    void main()
    {
        int k = 8;
        int m = 7;
        k < m ? k = k + 1 : m = m + 1;
        printf("%d", k);
    } 

6. What will be the final value of c in the following C code snippet? (Initial values: a = 1, b = 2, c = 1)

       c += (-c) ? a : b;

7. Which expression has to be present in the following?

exp1 ? exp2 : exp3;

 

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.