Manipulation of Arrays #1 - How to take input in array



This article will help you to understand how to take a multiple-input from the user, and store it in an array.
If you want to print the values of the array variables, then use printf() instead of scanf()




// Include required header files
//STD-IO refers to standard input/output
#include

//Execution of program starts from here
int main()

{
    //Declare  a variable and array of 10 integers
    int i, arr[10];

    //Run a for loop for 10 integers
    for(i=0; i<10 i="" p="">    {
        //Read input from the user for indexing variables
        scanf("%d", &arr[i]);
    }
    //Successful execution will return 0
    return 0;
}


Comments