How to Take Multiple Input in C? Last Updated : 25 Jun, 2024 Comments Improve Suggest changes Like Article Like Report 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. Multiple Inputs From a User in CTo take multiple inputs from users in C, we can declare an array to store the user input and repeatedly call the scanf() 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 fgets() function can be used to read strings with spaces. C Program to Take Multiple Inputs from the UserThe below program demonstrates how we can take multiple inputs from the users in C. C // C Program to Take Multiple Inputs from User #include <stdio.h> int main() { // Declare variables to hold the number of integers and // loop index int n, i; // Prompt the user to enter the number of inputs they // want to enter printf( "Enter the number of integers you want to input: "); scanf("%d", &n); // Declare an array of size n to hold the integers int arr[n]; printf("Enter %d integers:\n", n); // Loop to read n integers from the user for (i = 0; i < n; i++) { scanf("%d", &arr[i]); } // Print the integers entered by the user printf("You entered:\n"); for (i = 0; i < n; i++) { printf("%d ", arr[i]); } printf("\n"); return 0; } Output Enter the number of integers you want to input: 5Enter 5 integers:1020304050You entered:10 20 30 40 50 Time Complexity: O(N), here N denotes the number of inputs.Auxiliary Space: O(N) Comment More infoAdvertise with us Next Article How to Take Multiple Input in C? A abhay94517 Follow Improve Article Tags : C Programs C Language c-input-output C Examples Similar Reads How to Take Operator as Input in C? In C, an operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. We may need to take operator as an input in some cases. In this article, we will learn how to take an operator as input in C. Get Input Operator in CTo take an operator as input in C, we 2 min read How to Read Input Until EOF in C? In C, reading input until the End of the File (EOF) involves reading input until it reaches the end i.e. end of file. In this article, we will learn various methods through which we can read inputs until EOF in C.Reading Input Until EOFRead Input Until EOF Using getchar()Read Input Until EOF Using f 5 min read C Multiple Choice Questions C is the most popular programming language developed by Dennis Ritchie at the Bell Laboratories in 1972 to develop the UNIX operating systems. It is a general-purpose and procedural programming language. It is faster than the languages like Java and Python. C is very versatile it can be used in both 4 min read How to Read a File Line by Line in C? In C, reading a file line by line is a process that involves opening the file, reading its contents line by line until the end of the file is reached, processing each line as needed, and then closing the file.Reading a File Line by Line in CReading a file line by line is a step by step:1. Opening th 3 min read Convert String to int in C In C, we cannot directly perform numeric operations on a string representing a numeric value. We first need to convert the string to the integer type. In this article, we will discuss different ways to convert the numeric string to integer in C language.Example:Input: "1234"Output: 1234Explanation: 6 min read How to Split a String by Multiple Delimiters in C? In C, strings are arrays of characters using string manipulation often requires splitting a string into substrings based on multiple delimiters. In this article, we will learn how to split a string by multiple delimiters in C.ExampleInput:char inputString[] = "Hello,World;This|is.GeeksForGeeks";char 2 min read How to write in a file using fputs() in C fputs() is a function declared in stdio.h header file. It is used to write the contents of the file. The function takes 2 arguments. The first argument is a pointer to the string which is to be written and the second argument is the pointer of the file where the string is to be written. It returns 1 2 min read Program to find out the data type of user input Take a input from user and find out the data type of input value. Examples : Input : geek Output : The input is a string Input : chetna Output : The input is a string Input : 4 Output : The input is a integer Below is C program to find the datatype of user input : C // C program to find data type #i 2 min read How to Write a Command Line Program in C? In C, we can provide arguments to a program while running it from the command line interface. These arguments are called command-line arguments. In this article, we will learn how to write a command line program in C. How to Write a Command Line Program in C? Command line arguments are passed to the 2 min read How to Read a Paragraph of Text with Spaces in C? In C, we may need to read the input entered by the user that includes the paragraph of text with spaces. In this article, we will learn how to read a paragraph of text with spaces in C. Reading a Paragraph with Space in CIn C, reading a paragraph of text that includes spaces can be done by using fge 2 min read Like