How to Take Multiple Input from User in C++? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 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 T technoayan7 Follow Improve T technoayan7 Follow Improve Article Tags : C++ cpp-input-output CPP Examples Explore C++ BasicsIntroduction to C++3 min readData Types in C++6 min readVariables in C++4 min readOperators in C++9 min readBasic Input / Output in C++3 min readControl flow statements in Programming15+ min readLoops in C++7 min readFunctions in C++8 min readArrays in C++8 min readCore ConceptsPointers and References in C++5 min readnew and delete Operators in C++ For Dynamic Memory5 min readTemplates in C++8 min readStructures, Unions and Enumerations in C++3 min readException Handling in C++12 min readFile Handling in C++8 min readMultithreading in C++8 min readNamespace in C++5 min readOOP in C++Object Oriented Programming in C++8 min readInheritance in C++6 min readPolymorphism in C++5 min readEncapsulation in C++3 min readAbstraction in C++4 min readStandard Template Library(STL)Standard Template Library (STL) in C++3 min readContainers in C++ STL2 min readIterators in C++ STL10 min readC++ STL Algorithm Library3 min readPractice & ProblemsC++ Interview Questions and Answers1 min readC++ Programming Examples4 min read Like