Thread: How to input 2 inputs in 1 line???

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    4

    How to input 2 inputs in 1 line???

    I am going to input 2 different values in 1 line, how can i do that?

    if i use:
    cout << "Enter the value x: ";
    cin >> x;
    cout << "Enter the value y: ";
    cin >> y;

    the output:
    Enter the value x: 8
    Enter the value x: 6

    how can i do that(the output):

    Enter the value of x and y: 8 6

    thanks

  2. #2
    Spaced Cadet
    Join Date
    Aug 2003
    Posts
    110
    cin >> x;
    cin >> y;

    --or--

    cin >> x >> y;

    note: both require values to be separated by either a line-break or a white-space.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Line of data input method
    By larry_2k4 in forum C Programming
    Replies: 2
    Last Post: 04-28-2009, 11:34 PM
  2. Checking array for string
    By Ayreon in forum C Programming
    Replies: 87
    Last Post: 03-09-2009, 03:25 PM
  3. Replies: 11
    Last Post: 10-07-2008, 06:19 PM
  4. reading input problems
    By gonzad in forum C Programming
    Replies: 1
    Last Post: 08-26-2008, 04:00 AM
  5. Greenhand want help!
    By leereg in forum C Programming
    Replies: 6
    Last Post: 01-29-2002, 06:04 AM