I have a task to disply user entered values in a single line while using cin and cout objects.
Any one can help me to understand this??
My question is when a user enter a value in any veriable, cursor sholud not move to the next line...
Please help if anybody knows

5 Years
Discussion Span
Last Post by Ancient Dragon
int main()
    int a,b,sum;
    cout<<" Value A : ";
    cout<<" Vale B : ";
    cout<<" Sum of A and B : " <<sum;
    return 0;

Out put is:

Value A: 60
value B: 40
Sum of A and B : 100

I want out out in this form:

Value of A: 60 Value of B: 40 Sum of A and B : 100
mean to say in one line,
no three lines due to cin and cout....
Please Help...

Edited by mike_2000_17: fixed formatting


You can pull everything with a single cin call, provided the two items are separated by whitespace during input:

cin >> a >> b;

Adjust your prompts to that and it'll be closer to what you want. However, if you want free form control over the console, you'd be better off moving to a GUI than trying to make the console do something it's not well suited to do.


My Question is still there,
This in not suitable answer,
please add something like bach space code here or anything else..
but this inswer is not right....


This in not suitable answer

Because there's not a suitable answer for console mode applications. If you want that kind of control you have three options, ranging from bad to high learning curve:

  1. Take control of the input shell with raw input (incomplete and kludgy)
  2. Use a curses library to turn the console into more of a GUI.
  3. Use an actual GUI library.

You're not going to get the result you want easily, regardless of which approach you take.

but this inswer is not right....

Just because it's not what you wanted to hear doesn't mean it's not right.

Edited by deceptikon


but i have adjusted this through gotoxy(16,1);
now it is just what i wanted...
Thanks for help guys,
But i am sure anyone who will search for this matter will be getting help from this thread..


Congratulations, you picked the worst possible option. But I wish you the best of luck in your future endeavors.


But i am sure anyone who will search for this matter will be getting help from this thread..

Not likely to happen because you are using a 30-year-old compiler (Turbo C), right?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.