Some C++ Code
Posted: May 21st, 2004, 2:59 pm
Code: Select all
void showGraph( void );
double a[10];
int main(int argc, char *argv[])
{
cout << "SMARTWEB'S NUMBER ADDITION PROGRAM\n\n";
int sum = 0, count = 0;
bool done;
for (int i = 0; i<=9; i++)
{
if (!(i == 0))
{
if (a[i-1] == 0)
done = true;
}
if (!done)
{
cout << "NUMBER: ";
cin >> a[i];
count++;
sum += a[i];
}
}
cout << "\n";
cout << "NUMBER GRAPH\n";
showGraph();
cout << "\n";
count--;
cout << "\n";
cout << "SUM: " << sum;
cout << "\nCOUNT: " << count << "\n";
cout << "AVERAGE: " << sum / count << "\n\n";
return 0;
}
void showGraph( void )
{
for (int x = -1; x<=9; x++)
{
for (int y = 0; y<=10; y++)
{
if (x < 0)
cout << y;
else
{
if (!(a[x] == 0))
{
if(a[x] == y)
cout << "X";
else
cout << " ";
}
}
cout << " ";
}
if (!(a[x] == 0) || (x == -1))
cout << "\n";
}
cout << "\n";
}