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

Where should the cursor move to? Can you show us how the input should be formated?

#include<iostream.h>
#include<stdio.h>
#include<conio.h>
int main()
{
    clrscr();
    int a,b,sum;
    cout<<" Value A : ";
    cin>>a;
    cout<<" Vale B : ";
    cin>>b;
    sum=a+b;
    cout<<" Sum of A and B : " <<sum;
    getch();
    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...

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.

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.