that's your 0.33 attempt to get an answer on your question, yet however your question does not make experience... what do you advise by way of skill of functional quantity? What are you attempting to do/benefit? Rephrase your question / upload information by way of skill of declaring what you have, what you wanna do and what you prefer to realize. .
Answers & Comments
Verified answer
int data[10];
int index = 0;
for (int i = 9; i >= 0; i--)
{
data[index] = i+1;
index++;
}
//print the array
for (int i = 0; i < 10; i++)
cout << data[i] << endl;
well, you could use a for loop counting forwards, but filling in the values from the end to the beginning.
we want to put a 1 in position 9, a 2 in position 8 and finally a 10 in position 0. so basically we want to put a 10-i in position i.
like this:
int data[10];
for (int i=1; i<=10; i++) {
data[10-i] = i;
}
now to print out you can do:
cout<<"[ ";
for (int i=0; i<10; i++) {
cout<<data[i]<<" ";
}
cout<<']'<<endl;
}
Try this (sample run): http://ideone.com/GTiY8
------------
#include <iostream>
using namespace std;
int main()
{
int data[10];
int start=10;
for(int x=0; x < 10; ++x, --start)
{
data[x] = start;
}
for(int x=0; x < 10; ++x)
{
cout<<data[x]<<" ";
}
return 0;
}
that's your 0.33 attempt to get an answer on your question, yet however your question does not make experience... what do you advise by way of skill of functional quantity? What are you attempting to do/benefit? Rephrase your question / upload information by way of skill of declaring what you have, what you wanna do and what you prefer to realize. .