# Languages-C & C Plus Plus [Redpine Infotech Placement]: Sample Questions 1 - 2 of 5

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

## Question 1

C & C Plus Plus

### Question

MCQ▾

What is output for the following program?

1. `#include<stdio.h>`
2. `main ()`
3. `{`
4. `    int n=2;`
5. `    int sum=5;`
6. `    switch (n)`
7. `    {`
8. `        case 2:sum=sum-2;`
9. `        case 3:sum ⚹=5;`
10. `        break;`
11. `        default:sum=0;`
12. `    }`
13. `    printf (“%d” sum);`
14. `}`

### Choices

Choice (4)

a.

6

b.

15

c.

0

d.

None of the above

b.

### Explanation

 #include < tdio. h > Standard library function main () startup after initialization int n = 2;int sum = 5; Declare integer value n = 2 and sum = 5 switch (n) Switch in n, n = 2, so switch (2) case 2: sum = sum-2;case 3: sum ⚹= 5; In case: 2Sum = sum-2, so, sum = 5 - 2 = 3As there is no break after this case execution continues to next case.In case: 3Sum ⚹= 5, thus, sum = 3 ⚹ 5 = 15so, sum = 15 break; Switch breaks and sum = 15 default: sum = 0; This statement is not checked printf ( “% d” sum) ; Print sum = 15

## Question 2

C & C Plus Plus

### Question

MCQ▾

What is output for the following program?

1. `#include<stdio.h>`
2. `main ()`
3. `{`
4. `    int a=10, b=5;`
5. `    if(a=a&b)b=ab;`
6. `    printf (“a=%d, b=%d” a, b);`
7. `}`

### Choices

Choice (4)

a.

a = 0, b = 5

b.

a = 10, b = 5

c.

a = 0, b = 0

d.

None of the above