#include <iostream> #include <iomanip> using namespace std; const double g = 32.2; double FallingDistance(double t); double t; double distance; int main() { cout << "Seconds \tDistance\n"; cout << "==========================\n"; for (double t = 1; t <= 12; t++) { cout << t; cout << "\t\t" << FallingDistance(t) << endl; } return 0; } double FallingDistance(double t) { return (0.5*32.2*pow(t, 2)); } Last edited: 15-Oct-14 04:23 PM
user01 · Oct 15, 2014 4:20 PM · 4,577 views
Per documentation my results should show as follows: Seconds Distance ================ 1 16.1000 2 64.4000 3 144.9000 4 257.6000 5 402.5000 6 579.6000 7 788.9000 8 1030.4000 9 1304.1000 10 1610 11 1948.1000 12 2318.4000 I can't get it show decimal places, can anyone shed some light with this question. Also, I have tried placing setprecision (4) in my cout statement with no change. HELP
user01 · Oct 15, 2014 4:22 PM
this link might be helpful..:) http://stackoverflow.com/quest...
thapa solti · Oct 15, 2014 6:13 PM
This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.
Start a New Discussion