Question:
I have problem in c++ please help me?
Emad
2009-10-24 16:24:21 UTC
include;
#include;

using namespace std;

int main ()
{
float q=1.60206E-19; // Charge of the electron
float m=9.1083E-31; // mass of the electron
float v; // accelerating voltage in volts
cout<<"Pls enter v value"< cin>> v ;
float r1; // radius of the inner tube (cathode)
cout<<"Pls enter r1"< cin>>r1;
float r2; // radius of the outer tubr (anode)
cout<<"Pls enter r2"< cin>>r2;
float z=log(r2/r1);
float time;
time=sqrt((2*m)/(q*v)))*(r1)*(z)*((1)+(z/3)+(pow(z,2.0)/10)+(pow(z,3.0)/42)+(pow(z,4.0)/216);//there is a problem
cout<<"v="v<
system("pause");
return 0;
}
Three answers:
Brandyn S
2009-10-24 16:39:00 UTC
Well, it would be most helpful to see the formula you are trying to apply in your program.



time=sqrt((2*m)/(q*v)))...



Perhaps you copied your source code incorrectly but you have an extra closing paranthesis.



Try:



time=sqrt((2*m)/(q*v))...



It should then compile.



Good luck!
Ratchetr
2009-10-24 16:35:44 UTC
Yahoo has this annoying habit of cutting of strings that have no spaces.



Can you post the last couple lines again. Put a space before each ( and after each ) and it shouldn't get cut off.



But what is the problem?

Won't compile? -- Include the compiler error.

Doesn't produce the expected result? -- Include the expected result.
2009-10-24 16:51:55 UTC
Hm....



















1. checks the formula, where is the error, eg. divide by zerro or floating point overflow.

2. partition the formulas, where is divisor number or visor number.

eg: x = (-b - sqrt (b*b - 4*a*c)) / (2*a); very usefull if we partition the formulas with:

d = sqrt(b*b - 4*a*c);

x = (-b - d)/(2*a)


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...