Hello Fayezilla,
Last night I saw this post. This morning I find that it has been reported. Unfortunately I do not know why.
In a different topic
http://www.cplusplus.com/forum/beginner/271546/#msg1170794 you wrote:
Again I apologize for posting a question when I was unclear of the instructions.
|
So why have you not learned? This question is very confusing.
The word "components" may work, but it is not the proper term. When dealing with arrays, or something that has a base of an array, the more proper term is "element".
What you have posted is a bit unclear leaving a lot to guess work and interpretation. And my guess may not be what you want.
It should not matter what the setting is for loops and arrays should be covered early in class before you have to use them. Then the programs are built of of what you have learned.
It is easy to see that you need an array for this program. And if you do not want to hard code each element of the array you will need a for loop to do this for you.
I came up with this for a start. Sorry if I have done something that you have not learned about yet.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
#include <iomanip>
#include <string>
#include <limits>
int main()
{
constexpr double MEASUREMENT{ 1.5 };
constexpr int MAXSIZE{ 51 };
double arr[MAXSIZE]{};
std::cout << std::fixed << std::setprecision(2);
for (int idx = 1; idx < MAXSIZE; idx++)
{
arr[idx] = arr[idx - 1] + MEASUREMENT;
}
|
This is only part of the whole program, but it should give you an idea of where to start.
One big difference I did here was to make the array 1 larger than needed and not use element zero of the array except in this for loop. Your array would look something like this:
0. 0.00
1. 1.50
2. 3.00
3. 4.50
4. 6.00
5. 7.50
6. 9.00
7. 10.50
8. 12.00
9. 13.50
10. 15.00
11. 16.50
.
.
.
50. 75.00
|
Everything including the ". " is just a counting number to show the array elements.
By skipping element zero it makes the next for loop easier to work with. This is not the norm, but a special case.
Work up some code to finish the program and we can discus why it works or does not work.
Andy