input many values in C++

In C++, you can allow a user to input value from keyword by using stream input cin.

For example, to input a number from keyboard, you can write as the following:

int x;

cin>>x;

You also can input many values by writing only a single line of code.

Example:

#include <cstdlib>
#include <iostream>

int main(){
 

   int x, y, z, a, b, c;


   cin>>x>>y>>z>>a>>b>>c;

  system("PAUSE");

  return 0;

}



Note: When inputting, press space bar or enter key to separate those values.

Posted by: Dara | post date: 11-25-2012 | Subject: C++ Programming Language




This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.