(Take the first element and display all the elements after it, take the second element and display all the elements after it, take the third element and ...)
Last edited by tux4life; May 16th, 2009 at 4:37 am.
That's already a lot better, you're making progress
To find the length of the array you can do something like this: const int count=sizeof(array)/sizeof(int); or, if your array is always of the same length: const int count=4;
( const is optional in both cases, but I would recommend it in the second one)
for (i=0;i<=count;i++) has to be: for (i=0;i<count;i++) (otherwise you're overriding the array's bounds)
Now you've already the code to print out the whole array you've already completed 30% of your homework
Last edited by tux4life; May 16th, 2009 at 6:23 am.
You've to run the loop three times (the number of elements in the array decreased by one)
Every time you display all the elements coming after the element, so if you've 10, you're displaying each time 10+ '20,30,40', for 20 it's the same: 20+ '30,40', and so on
>>but problem is how to make this dynamic??
What do you mean by dynamic?
BTW, do you realize that the code which you have written is no where near to c++?
This is a C code. And you participate in a C++ forum. No doubt you have a red dot on the reputation bar.
C++ is not C. There is a hell lot of difference between these two language.
You should start learning C++. Buy some books like Accelerated C++ and learn the language first.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.