Some C++ Code

Code help, language discussions, and software development advice.
Post Reply
Smartweb
Registered User
Posts: 622
Joined: January 15th, 2004, 2:11 am
Contact:

Some C++ Code

Post by Smartweb »

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";
}
Aggressor Prime
Registered User
Posts: 923
Joined: January 15th, 2004, 1:51 am
Location: PTMC Headquarters
Contact:

Post by Aggressor Prime »

Very nice. But would you mind to give an in-depth discusion on what this code does for all of our non C++ programmers out here? I'm guessing it is a calculator program, but you can explain it better.
Last edited by Aggressor Prime on May 21st, 2004, 3:17 pm, edited 1 time in total.
Athlon XP 3200 3DMark05 Score: 3460 GeForce 6600 GT 3DMark05 Score: 3132 14304 SETI Results: Athlon 64 2800 Athlon XP 3200 Athlon XP 2100 Athlon XP 1800 Pentium 3 Celeron 667MHz If you haven't played Descent 3, you aren't a gamer.
Smartweb
Registered User
Posts: 622
Joined: January 15th, 2004, 2:11 am
Contact:

Post by Smartweb »

For non C++ programmers, what use is looking at this code whatsoever?
Aggressor Prime
Registered User
Posts: 923
Joined: January 15th, 2004, 1:51 am
Location: PTMC Headquarters
Contact:

Post by Aggressor Prime »

So they can learn. This is a free computer help forum.
Athlon XP 3200 3DMark05 Score: 3460 GeForce 6600 GT 3DMark05 Score: 3132 14304 SETI Results: Athlon 64 2800 Athlon XP 3200 Athlon XP 2100 Athlon XP 1800 Pentium 3 Celeron 667MHz If you haven't played Descent 3, you aren't a gamer.
Smartweb
Registered User
Posts: 622
Joined: January 15th, 2004, 2:11 am
Contact:

Post by Smartweb »

This is a reference for people who know C++, not a tutorial.
Aggressor Prime
Registered User
Posts: 923
Joined: January 15th, 2004, 1:51 am
Location: PTMC Headquarters
Contact:

Post by Aggressor Prime »

Where is the tutorial on this forum?
Athlon XP 3200 3DMark05 Score: 3460 GeForce 6600 GT 3DMark05 Score: 3132 14304 SETI Results: Athlon 64 2800 Athlon XP 3200 Athlon XP 2100 Athlon XP 1800 Pentium 3 Celeron 667MHz If you haven't played Descent 3, you aren't a gamer.
Smartweb
Registered User
Posts: 622
Joined: January 15th, 2004, 2:11 am
Contact:

Post by Smartweb »

There is none.
lilhawk2892
Registered User
Posts: 2
Joined: August 19th, 2005, 1:01 am

Post by lilhawk2892 »

just tell us wut it does i use c++
Post Reply