Cubic Numbers

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2005
Posts: 34
Reputation: Mike182 is an unknown quantity at this point 
Solved Threads: 0
Mike182's Avatar
Mike182 Mike182 is offline Offline
Light Poster

Cubic Numbers

 
0
  #1
Aug 9th, 2005
How to i get cubic numbers into a program?
Ive tried ^3, but in this line:


x = creat^3;
y = lines*20;
z = x+y;
cout<<"Your zenii for this post is " << z << ".\a" << endl;

If i change the cout to call out x it calls it out as 0, when i input the creat i use 3, so it should cube it to 27, but it calls out 0, why is this? How can i fix it?
Reply With Quote Quick reply to this message  
Join Date: Apr 2003
Posts: 46
Reputation: Dante Shamest is an unknown quantity at this point 
Solved Threads: 0
Dante Shamest's Avatar
Dante Shamest Dante Shamest is offline Offline
Light Poster

Re: Cubic Numbers

 
0
  #2
Aug 9th, 2005
The operator ^ is the bitwise XOR operator, not a cubic operator. There isn't a cubic operator. You can get the 3rd power of a number by using * like this:

  1. int n = 2 * 2 * 2 ;
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 34
Reputation: Mike182 is an unknown quantity at this point 
Solved Threads: 0
Mike182's Avatar
Mike182 Mike182 is offline Offline
Light Poster

Re: Cubic Numbers

 
0
  #3
Aug 9th, 2005
But how would i convert that into what i need? The number i want cubed is creat, and it is a user input number,
so for example the creat input is 6
I want it to take six and cube it, how would i do that?
Reply With Quote Quick reply to this message  
Join Date: Apr 2003
Posts: 46
Reputation: Dante Shamest is an unknown quantity at this point 
Solved Threads: 0
Dante Shamest's Avatar
Dante Shamest Dante Shamest is offline Offline
Light Poster

Re: Cubic Numbers

 
0
  #4
Aug 9th, 2005
Not sure if I follow, but what about

  1. creat = creat * creat * creat;
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 34
Reputation: Mike182 is an unknown quantity at this point 
Solved Threads: 0
Mike182's Avatar
Mike182 Mike182 is offline Offline
Light Poster

Re: Cubic Numbers

 
0
  #5
Aug 9th, 2005
Hmmm it still doesnt work, when i use that and change the cout to call out what x equals
'x = creat;' with what you told me to int creat as, it calls out 3 when i input the creat as 3, when it should call out 27 =/
Reply With Quote Quick reply to this message  
Join Date: Apr 2003
Posts: 46
Reputation: Dante Shamest is an unknown quantity at this point 
Solved Threads: 0
Dante Shamest's Avatar
Dante Shamest Dante Shamest is offline Offline
Light Poster

Re: Cubic Numbers

 
0
  #6
Aug 9th, 2005
Perhaps you mean to do

  1. x = creat * creat * creat;

Anyway please post your code again after you've made any changes.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 34
Reputation: Mike182 is an unknown quantity at this point 
Solved Threads: 0
Mike182's Avatar
Mike182 Mike182 is offline Offline
Light Poster

Re: Cubic Numbers

 
0
  #7
Aug 9th, 2005
Ahhhhh, lol thanks thats got it working,
  1. else if(value == 1)
  2. {
  3. system("title AnimeDD Zenii Calculator");
  4. system("color 8E");
  5. cout <<"Alright time to calculate your Zenii, get your storyline ratings ready!" << endl;
  6. int lines, creat, x, y, z;
  7. cout<<"What is your characters name?"<< endl;
  8. cin>> name; (name,100);
  9. cout<<"Hello, " << name << "."<< endl;
  10. cout<<"Put in your creativity rating for the storyline post"<< endl;
  11. cin>> creat;
  12. cout<<"Thank you, Now put in your line count for the storyline post"<< endl;
  13. cin>> lines;
  14. x = creat*creat*creat;
  15. y = lines*20;
  16. z = x+y;
  17. cout<<"Your zenii for this post is " << z << ".\a" << endl;
  18. cout<< ""<< endl;
  19. cout<<"Q - Quit"<< endl;
  20. cout<<"R - Repeat"<< endl;
  21. cout<<"Please type in the corresponding letter for your choice then press enter."<< endl;
  22. cin>> quit;
  23. cout<<"Goodbye, " << name << "."<< endl;
  24. system("PAUSE");
  25. system("cls");
  26. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC