Hi,
I want to create a program and insert some numbers into an array
for example:
> test1 //start the program
2 4 6 5 3 20 30 60 50 40 //insert thoes values into array in the program
how can i do it?
Hi,
I want to create a program and insert some numbers into an array
for example:
> test1 //start the program
2 4 6 5 3 20 30 60 50 40 //insert thoes values into array in the program
how can i do it?
You've left out so many details I am unable to answer your question.
Mainframe assembler programmer by trade. C coder when I can.
You want to insert them by keyboarding them into the array?
Remember that all C arrays begin with array[0], and stop at array[size - 1]. So if your arrray has space for 10 items, the last number it can hold will be in array[9], not array[10].Code:int i, size_of_the_array; for(i = 0; i < size_of_ the_array; i++) { printf("\n Enter a number %d: ", i+1); scanf("%d", &array[i]); }
HOPE YOU UNDERSTAND.......
By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior
PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition
somthing more like:
int i, size_of_the_array;
printf("\n Enter a number %d: ", i+1);
scanf("%d", &array[i]);
// the input should be a lot of numbers with space between every two //
so i dont think the scanf above will work... maybe to insert all the number into a string and then work on the string... or somthing else... im not sure....
do u know how to do it?
thnx.
Use loops for that purpose, as Adak has already explained.
HOPE YOU UNDERSTAND.......
By associating with wise people you will become wise yourself
It's fine to celebrate success but it is more important to heed the lessons of failure
We've got to put a lot of money into changing behavior
PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
IDE- Microsoft Visual Studio 2008 Express Edition