# Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 269 - 269 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 269

C & C Plus Plus

### Question

MCQ▾

What is the output in the following program

1. `main ()`
2. `{`
3. `    char c =-64;`
4. `    int i =-32;`
5. `    unsigned int u =-16;`
6. `    if (c>i)`
7. `    {`
8. `        printf("pass1,");`
9. `        if(c)`
10. `        printf ("pass2,");`
11. `        else`
12. `        printf ("Fail2");`
13. `    }`
14. `    else`
15. `    printf ("Fail1,");`
16. `    if (i)`
17. `    printf ("pass2");`
18. `    else`
19. `    printf ("Fail2");`
20. `}`

Choice (4)

a.

Pass1, fail2

b.

Fail1, fail2

c.

Pass1, pass2

d.

Fail1, pass2

d.

### Explanation

• In the program
 char c =-64; Define the character variable c =-64 int i =-32; Define the integer variable i =-32 unsigned int u =-16; Define the unsigned integer u =-16 `if (c >i)``{``    printf(“pass1,“);``    if(c)``    printf (“pass2,“);``    else``    printf (“Fail2”);``}``else``printf (“Fail1,“);` Check the if condition`if (-64 >-32)``{``    printf(“pass1,“);``    if(c)``    printf (“pass2,“);``    else``    printf (“Fail2”);``}``else``printf (“Fail1,“);`Here if condition is false because -64 is less -32So, else condition is appliedAnd printf prints “Fail1” `if (i)``printf (“pass2”);``else``printf (“Fail2”);` Check the if condition`if (-32)``printf (“pass2”);``else``printf (“Fail2”);`Here if condition is trueSo, printf prints “pass2”

Developed by: