178k views
2 votes
1. What is theoutput of the following code fragment if the input values are 1 and2?

int x;
int y;
cin>>x;
cin>>y;
cout< cout< A. 1
2
B. 1 2
C. 12
D. xy

1 Answer

4 votes

Answer:

Hi, in the last one a correct way of the code will be:

cout<<x<<y;

or

cout<<x;

cout<<y;

In the first case you get 12, the C.

In the second case you also get the C.

Step-by-step explanation:

If you want to make a jump line you have to use endl

e.g.

cout<<x<<endl;

cout<<y<<endl;

And after this you get:

1

2

In the other ways, you get the previously result in the output.

I hope it's help you.

User Brian Behm
by
7.7k points