VOOZH about

URL: https://www.geeksforgeeks.org/cpp/how-to-take-multiple-input-from-user-in-cpp/

⇱ How to Take Multiple Input from User in C++? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to Take Multiple Input from User in C++?

Last Updated : 23 Jul, 2025

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 User

The below example demonstrates how we can take multiple inputs from a user in C++.


Output

Enter the number of elements you want to input: 5
Enter 5 numbers: 1 2 3 4 5
You entered: 1 2 3 4 5

Time Complexity: O(n), where n is the number of elements you want to enter.
Space Complexity: O(n)



Comment
Article Tags: