Exponitial Loop

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2007
Posts: 14
Reputation: tayster is an unknown quantity at this point 
Solved Threads: 0
tayster tayster is offline Offline
Newbie Poster

Exponitial Loop

 
0
  #1
Mar 23rd, 2007
this is about making a loop for powers

stripe3 is the variable
how do u do stripe3*10 stripe3 times
for example if stripe3 = 5
then my question is how do u do 5*10 5 times
because there isnt an opperation in c++ for exponents
so i was thinking of making a loop but i can't figure out
how to write a loop for this ?

also sence before hand i am going to have a user input a value for a couple things including stripe3 and then the loop will calculate then out put the answer any ways im wondering if i should use cin and cout or printf and scanf for the user input stuff also i cant seem to figure out how to combine a user input with cin and cout with loops and if else statements and the data after compiled comes out wrong.

could you guys help me out with this i'd apreaciate it thanks.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Exponitial Loop

 
0
  #2
Mar 23rd, 2007
>because there isnt an opperation in c++ for exponents

There isn't? I think there is.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 14
Reputation: tayster is an unknown quantity at this point 
Solved Threads: 0
tayster tayster is offline Offline
Newbie Poster

Re: Exponitial Loop

 
0
  #3
Mar 23rd, 2007
o i just looked at something and what it said under math.h was
exe ()
could this be it and if it is i dont have a clue how to use it
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Exponitial Loop

 
0
  #4
Mar 23rd, 2007
no that's not it.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 14
Reputation: tayster is an unknown quantity at this point 
Solved Threads: 0
tayster tayster is offline Offline
Newbie Poster

Re: Exponitial Loop

 
0
  #5
Mar 23rd, 2007
well i have looked in alot of places and i cant find one if u know it could u tell me?
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,031
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: Exponitial Loop

 
0
  #6
Mar 23rd, 2007
#include <math.h>

pow(base, exponent);
Last edited by Aia; Mar 23rd, 2007 at 6:48 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 14
Reputation: tayster is an unknown quantity at this point 
Solved Threads: 0
tayster tayster is offline Offline
Newbie Poster

Re: Exponitial Loop

 
0
  #7
Mar 23rd, 2007
ok i created a program for it but now how do i output the result?

  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. float a,b,c;
  8. a=0;
  9. b=0;
  10. cout<<"enter first stripe number"<<endl;
  11. cin>>a;
  12. cout<<"enter second stripe number"<<endl;
  13. cin>>b;
  14. pow(a,b);
  15.  
  16.  
  17. system ("pause");
  18. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,031
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: Exponitial Loop

 
0
  #8
Mar 23rd, 2007
a_variable_float = pow(a,b);
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 14
Reputation: tayster is an unknown quantity at this point 
Solved Threads: 0
tayster tayster is offline Offline
Newbie Poster

Re: Exponitial Loop

 
0
  #9
Mar 23rd, 2007
so like this?
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5. int main()
  6. {
  7. float a,b,c;
  8. a=0;
  9. b=0;
  10. cout<<"enter first stripe number"<<endl;
  11. cin>>a;
  12. cout<<"enter second stripe number"<<endl;
  13. cin>>b;
  14. a_variable_float = pow(a,b);
  15.  
  16. system ("pause");
  17. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 2,031
Reputation: Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of Aia has much to be proud of 
Solved Threads: 177
Aia's Avatar
Aia Aia is offline Offline
Postaholic

Re: Exponitial Loop

 
0
  #10
Mar 23rd, 2007
Originally Posted by tayster View Post
so like this?
What I meant was:

Declare another float or better yet a double variable at the begining of
main. Then assign the result of the pow function to that variable.

Then do what you wish with that result that is in the variable.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



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