• Welcome to Valhalla Legends Archive.
 

My First c++ application

Started by BaDDBLooD, August 21, 2004, 02:15 PM

Previous topic - Next topic

MyndFyre

Quote from: $t0rm on August 23, 2004, 02:30 PM
Quote from: MyndFyre on August 23, 2004, 01:46 PM
Quote from: $t0rm on August 23, 2004, 01:03 PM
* $t0rm stops the personal attacks.

$t0rm, you stink!

myndfyre, youre a microsoft sellout. :-P

Can you blame me?  I can't find a wireless network card that works with Linux.  When I tried installing Linux today on my PC, it came close to blowing up (I can't get any kind of GUI whatsoever).
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Adron

Quote from: MyndFyre on August 23, 2004, 05:14 PM
Can you blame me?  I can't find a wireless network card that works with Linux.  When I tried installing Linux today on my PC, it came close to blowing up (I can't get any kind of GUI whatsoever).

Did you check this page?

Newby

- Newby

Quote[17:32:45] * xar sets mode: -oooooooooo algorithm ban chris cipher newby stdio TehUser tnarongi|away vursed warz
[17:32:54] * xar sets mode: +o newby
[17:32:58] <xar> new rule
[17:33:02] <xar> me and newby rule all

Quote<TehUser> Man, I can't get Xorg to work properly.  This sucks.
<torque> you should probably kill yourself
<TehUser> I think I will.  Thanks, torque.

Grok

He apparently wants to make lots of money and have a good life, big house, giant yard, wife with big titties and great legs, a home theatre, pool, etc.

I know this to be true because otherwise he would be using Linux.

Banana fanna fo fanna

Grok, you know me, I'm anti-Linux for the desktop, and I think ASP.NET is cool.

AntiVirus

#35
#include <iostream.h>

int main()
{

  int choice;
  float number1;
  float number2;
  char indicator;

  cout << "1) Addition" << endl
      << "2) Subtraction" << endl
       << "3) Multiplication" << endl
       << "4) Division" << endl;

  do
  {
     cout << "Enter First Digit: ";
     cin >> number1;

     cout << "Enter Second Digit: ";
     cin >> number2;

     cout << "Choose Operator: ";
     cin >> choice;

     switch(choice)
     {
        case 1: cout << endl << "The answer is: " << number1 + number2 << endl;                  
              break;
        case 2: cout << endl << "The answer is: " << number1 - number2 << endl;                  
              break;
        case 3: cout << endl << "The answer is: " << number1 * number2 << endl;                  
              break;
        case 4: cout << endl << "The answer is: " << number1 / number2 << endl;                  
              break;
        default: cout << endl <<"You chose invalid selection" << endl;
     }

     cout << endl << "Do you want to enter another (y or n)? ";  
     cin >> indicator;
     cout << endl;
  } while((indicator == 'Y' || indicator == 'y'));

 return 0;
}


I tried this program out and I noticed that when you divide a smaller number by a bigger number you get 0.  I then changed it to "float number1" and "float number2" and I got a more correct result.  I don't know if this has been mentioned, but that is just something I found.  Even thought this is an old post, you still may care.
"They say that I must learn to kill before I can feel safe, but I rather kill myself then turn into their slave."
- The Rasmus

MyndFyre

#36
Quote from: iago on August 21, 2004, 02:17 PM
<edit> Don't take any of his advice in that thread, please.  It's not very good.

My discussion of not recursing the main() function is good!   :o

Quote from: Brandon on September 22, 2004, 05:16 PM
I tried this program out and I noticed that when you divide a smaller number by a bigger number you get 0.  I then changed it to "float number1" and "float number2" and I got a more correct result.  I don't know if this has been mentioned, but that is just something I found.  Even thought this is an old post, you still may care.
It depends on the kind of precision the project requires.  When working with floats, you tend to incur an exponentially larger delay in calculation processing.  That is, floating-point arithmetic is SLOW SLOW SLOW compared to integer arithmetic.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Mephisto

Quote from: MyndFyre on September 22, 2004, 07:04 PM
Quote from: iago on August 21, 2004, 02:17 PM
<edit> Don't take any of his advice in that thread, please.  It's not very good.

My discussion of not recursing the main() function is good!   :o

Quote from: Brandon on September 22, 2004, 05:16 PM
I tried this program out and I noticed that when you divide a smaller number by a bigger number you get 0.  I then changed it to "float number1" and "float number2" and I got a more correct result.  I don't know if this has been mentioned, but that is just something I found.  Even thought this is an old post, you still may care.
It depends on the kind of precision the project requires.  When working with floats, you tend to incur an exponentially larger delay in calculation processing.  That is, floating-point arithmetic is SLOW SLOW SLOW compared to integer arithmetic.

For a simple calculator application, it shouldn't really matter.  :)

Eibro

QuoteIt depends on the kind of precision the project requires.  When working with floats, you tend to incur an exponentially larger delay in calculation processing.  That is, floating-point arithmetic is SLOW SLOW SLOW compared to integer arithmetic.
That is incorrect. Perhaps on older processors this was true, but certainly not anymore.
Eibro of Yeti Lovers.

MyndFyre

Quote from: Eibro[yL] on September 23, 2004, 07:39 AM
QuoteIt depends on the kind of precision the project requires.  When working with floats, you tend to incur an exponentially larger delay in calculation processing.  That is, floating-point arithmetic is SLOW SLOW SLOW compared to integer arithmetic.
That is incorrect. Perhaps on older processors this was true, but certainly not anymore.

You're going to tell me that dividing two 8-byte double-precision numbers is the same speed as integer division?  Not on your life!  One division might not matter, but several million would!
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Eibro

Quote from: MyndFyre on September 23, 2004, 08:09 PM
Quote from: Eibro[yL] on September 23, 2004, 07:39 AM
QuoteIt depends on the kind of precision the project requires.  When working with floats, you tend to incur an exponentially larger delay in calculation processing.  That is, floating-point arithmetic is SLOW SLOW SLOW compared to integer arithmetic.
That is incorrect. Perhaps on older processors this was true, but certainly not anymore.

You're going to tell me that dividing two 8-byte double-precision numbers is the same speed as integer division?  Not on your life!  One division might not matter, but several million would!
It's a comparable speed. Then again, it depends on the processor. On some, floating point arithmetic can actually be faster. In any case, it does not "tend to incur an exponentially larger delay", as you claim.
Eibro of Yeti Lovers.

Mephisto

In VS.NET 2003 aren't there performance options to enhance performance for integer/floating-point arithmetic?  And isn't that implied on optimizations for Pentium 4/AMD processors; I saw an article about it from Microsoft explaining that that particular optimization enhances speed for artihmetic for those processors by using different instructions.

|