![]() |
VOOZH | about |
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++.
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.
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)