0
How can i assign array elements from user input in c
Please explain in detail because i am trying hard to understand this but couldn't.
1 Odpowiedź
+ 1
First create an array
int a[10];
Then use a for loop to accept each element from user.
for(int i=0;i<10;i++){a[i]=cin>>'enter element';}
This takes input for each data element and assigns it to the array.
So this loop runs 10 times cause that's the size of he array and each time an input is given,it is assigned to the array. The first input is assigned in a[0], second in a[1] and so on.