Originally Posted by
bluevitriol
Q) Write a program to take an input array of 10 elements from user using recursion.
Can anyone please write the code and also explain it to me????
I use C#, but maybe there's something similar in C...
Code:
string[] myArray=new string[10];//declare array and size, can be int if that's what youll ask for
for (int i =0; i<10; i++){// start at 0, until i is lower than 10, add one each time
Console.WriteLine("Enter value "+(i+1)+": ");//Write so the user knows they have to enter something.
string input = Console.ReadLine();// ask for input
myArray[i]=input;// add input to array
}
This is written in C#, i did it really fast, so no idea if i messed up somewhere, but its so you understand.
Im sure you can do the same in C.