# HCL Papers: Sample Questions 55 - 56 of 57

Examrace Placement Series prepares you for the toughest placement exams to top companies.

## Question number: 55

MCQ▾

### Question

What is the output of the following program?

1. `main()`
2. `{`
3. `    int x=20;`
4. `    int y=10;`
5. `    swap(x,y);`
6. `    printf("%d %d",y,x+2);`
7. `}`
8. `swap(intx,int y)`
9. `{`
10. `    Int temp;`
11. `    temp =x;`
12. `    x=y;`
13. `    y=temp;`
14. `}`

### Choices

Choice (4) Response

a.

20,12

b.

10,20

c.

10,22

d.

22,10

a.

### Explanation

• In the main () function two integer variables, x and y are initialized with 20 and 10 respectively. In the swap function we are passing two arguments, x and y. We want to swap the values stored in X and Y. For it we have first defined one temporary variable, temp. The next three lines is the code for interchanging the values of X and Y.
• temp = x, i. e. we are storing value of x in temp.
• x = y, i. e. we are storing value of y in x.
• y = temp, i. e. we are storing value of temp in y.
• Now, the values of x and y has been interchanged. So, now x is 10 and y is 20.
• We want to print the value of y and x + 2, which will be 20 and 12 respectively.

## Question number: 56

MCQ▾

### Question

What is the output of the following program? (. has been used to indicate a space)

1. `main()`
2. `{`
3. `    char s[]="Hello,.World";`
4. `    printf(%15.10s",s);`
5. `}`

### Choices

Choice (4) Response

a.

Hello, . Wor….

b.

Hello, . World…

c.

…. Hello, . Wor

d.

None of the above