Sunday, August 2, 2009

Using exponent in C++ Visual Basic 2005 Express Edition?

Pretty straightforward, how can you use exponents in C++ visual Basic 2005 Express edition. The internet has conspired against me, and the textbooks we are using are for a outdated C++ version. It would be most appreciated for someone to show me how to do a simple function such as (3.0 * 10^8) and show me which library to use.

Using exponent in C++ Visual Basic 2005 Express Edition?
//


// Done in Visual C++ 2005Express Edition


//


#include %26lt;iostream%26gt;


#include %26lt;math.h%26gt;





void main()


{


double val = 0.0;





val = 3.0 * pow(10.0, 8.0);


std::cout %26lt;%26lt; "3.0 * 10^8 = " %26lt;%26lt; val %26lt;%26lt; "\n";





val = pow(3.0, 8.0);


std::cout %26lt;%26lt; "3.0 ^ 8.0 = " %26lt;%26lt; val %26lt;%26lt; "\n";


}








///// --- output --- ////





3.0 * 10^8 = 3e+008


3.0 ^ 8.0 = 6561


No comments:

Post a Comment