| jsmi2016 (7) | |
|
I have the formula: #include <iostream> #include <cmath> using namespace std; int main() { double v,lo,l; cout << "Enter the proper length (m)of an object" << endl; cin >> lo; cout << "Enter the proper length of the object relative to the observer" >> endl; cin >> v; l = lo * sqrt(1.0000-(pow(v,2.0000)/pow(299792458.0000,2.0000))); cout.precision(4); cout << fixed << lo << endl; cout << fixed << v << endl; cout << fixed << l << endl; return 0; } This works, but the output is: ans.0000 ans.0000 ans.0000 I need the answer as: lo = ans.0000 v = ans.0000 l = and.0000 How do I do this? I don't know how to get it without a compiling error. | |
|
|
|
| Nahjil567 (25) | |
cout << "v = " << fixed << lo << endl; That should fix your problem.
| |
|
|
|