How to Take Multiple Input from User in C++? Last Updated : 14 Feb, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report In C++, we use cin when we want to take input from the user. We often also need to take more than one input at a time. In this article, we will learn how to take multiple inputs in C++. Take Multiple Inputs from a User in C++To take multiple inputs from users, we can repeatedly use the std::cin using loops. It will allow the user to enter the data till required. We can use any data container to store the data entered by the user. C++ Program to Take Multiple Inputs from UserThe below example demonstrates how we can take multiple inputs from a user in C++. C++ // C++ program to input multiple items #include <iostream> #include <vector> using namespace std; int main() { int n; // Input the number of elements cout << "Enter the number of elements you want to " "input: "; cin >> n; // Initialize a vector of size n vector<int> vec(n); // Input n numbers into the vector cout << "Enter " << n << " numbers: "; for (int i = 0; i < n; i++) { cin >> vec[i]; } // Output the entered numbers cout << "You entered: "; for (int i : vec) { cout << i << " "; } cout << endl; return 0; } Output Enter the number of elements you want to input: 5Enter 5 numbers: 1 2 3 4 5You entered: 1 2 3 4 5Time Complexity: O(n), where n is the number of elements you want to enter.Space Complexity: O(n) Comment More infoAdvertise with us Next Article How to Take Multiple Input from User in C++? T technoayan7 Follow Improve Article Tags : C++ cpp-input-output CPP Examples Practice Tags : CPP Similar Reads How to Take Input in Array in C++? Arrays in C++ are derived data types that can contain multiple elements of the same data type. They are generally used when we want to store multiple elements of a particular data type under the same name. We can access different array elements using their index as they are stored sequentially in th 3 min read How to use getline() in C++ when there are blank lines in input? In C++, if we need to read a few sentences from a stream, the generally preferred way is to use the getline() function as it can read string streams till it encounters a newline or sees a delimiter provided by the user. Also, it uses <string.h> header file to be fully functional. Here is a sam 2 min read Printing Output in Multiple Lines in C++ This article focuses on discussing how to use cout for multi-line printing. This can be easily done using any of these two methods: Using endl.Using \n. Let's discuss each of these methods in detail. Using endl The endl statement can be used to print the multi-line string in a single cout statement. 2 min read How to Read and Print an Integer value in C++ The given task is to take an integer as input from the user and print that integer in C++ language. In this article, we will learn how to read and print an integer value. In the below program, the syntax and procedures to take the integer as input from the user is shown in C++ language. Standard Inp 2 min read C++ Wait for User Input Waiting for User input is common functionality in any program requiring some form of user intervention. Whether it is halting the execution to see the output produced, or is it for taking in user input, halting the execution for input is one of the most common tasks that are performed by a program. 4 min read Like