943,585 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2592
  • C++ RSS
Aug 9th, 2005
0

Cubic Numbers

Expand Post »
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?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Aug 9th, 2005
0

Re: Cubic Numbers

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:

C++ Syntax (Toggle Plain Text)
  1. int n = 2 * 2 * 2 ;
Reputation Points: 13
Solved Threads: 0
Light Poster
Dante Shamest is offline Offline
46 posts
since Apr 2003
Aug 9th, 2005
0

Re: Cubic Numbers

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?
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Aug 9th, 2005
0

Re: Cubic Numbers

Not sure if I follow, but what about

C++ Syntax (Toggle Plain Text)
  1. creat = creat * creat * creat;
Reputation Points: 13
Solved Threads: 0
Light Poster
Dante Shamest is offline Offline
46 posts
since Apr 2003
Aug 9th, 2005
0

Re: Cubic Numbers

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 =/
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005
Aug 9th, 2005
0

Re: Cubic Numbers

Perhaps you mean to do

C++ Syntax (Toggle Plain Text)
  1. x = creat * creat * creat;

Anyway please post your code again after you've made any changes.
Reputation Points: 13
Solved Threads: 0
Light Poster
Dante Shamest is offline Offline
46 posts
since Apr 2003
Aug 9th, 2005
0

Re: Cubic Numbers

Ahhhhh, lol thanks thats got it working,
C++ Syntax (Toggle Plain Text)
  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. }
Reputation Points: 10
Solved Threads: 0
Light Poster
Mike182 is offline Offline
34 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: trial version of Microsft VC++
Next Thread in C++ Forum Timeline: Files & streams?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC