![]() |
VOOZH | about |
In C, we use scanf to take input from the user, and often it is necessary to take multiple inputs simultaneously. In this article, we will learn about how to take multiple inputs from the users in C.
To take multiple inputs from users in C, we can declare an array to store the user input and repeatedly call the function within loop to keep taking the inputs until required. While reading strings as inputs the user may encounter spaces, to deal with them the function can be used to read strings with spaces.
The below program demonstrates how we can take multiple inputs from the users in C.
Output
Enter the number of integers you want to input: 5
Enter 5 integers:
10
20
30
40
50
You entered:
10 20 30 40 50
Time Complexity: O(N), here N denotes the number of inputs.
Auxiliary Space: O(N)