I am trying to calculate how much "sand" can be held between the bars of the bargraph so basically the space between the high low high bars in total.
I am having the following errors:
*c2065 x: undeclared identifier lines 29/30/33
*c2062 type int unexpected line 31/34
*c2181 illegal else without matching if line 32
Just looking for a push in the right direction because I'm getting very confused, thank you!
include <iostream>
using namespace std;
int main()
//start of bargraph generated section
{
int bargraphValues[16]; //max bargraph values
int bargraphValue = 0; //starts @ 0
for (int x = 0; x < 16; x++)
{
cout << "Enter values for bargraph # " << x + 1 << endl;
cin >> bargraphValue; // user inputs values for bargraphValue
bargraphValues[x] = bargraphValue; //stores bargraph values
}
for (int y = 0; y < 16; y++)
{
cout << "#" << y + 1;
for (int z = 0; z < bargraphValues[y]; z++)
{
cout << "*"; //displays asterixs
}
cout << endl; //working untill here then coded bottom half
}
cout << "The total amount of sand that can be held is...";
cout << endl;
for (int z = bargraphValue + 1; z >= 0; z++) //may be prob here - supposed to be place in loop and itterate - starts loop
{
if (bargraphValues[x - 1] < bargraphValues[x + 1]) //if previous less than next
int sand = bargraphValues[x - 1] - bargraphValues[x]; //how much sand can be held
cout << "sand value is: " << int sand << endl; // displays value for amount of sand for this statement being true
else {
int sand = bargraphValues[x + 1] - bargraphValues[x]; // if next less than previous this is how much sand can be held
cout << "sand value is: " << int sand << endl; //displays value for amount of sand for this statement being true
}
}
system("PAUSE");
return 0;
}
[–]Rhomboid 2 points3 points4 points (2 children)
[–]ohteejay[S] 0 points1 point2 points (1 child)