- #1
wahaj
- 156
- 2
Homework Statement
can some one tell me what I am doing wrong in this program. I am getting a
error C2296: '^' : illegal, left operand has type 'double'
error at line 10 where I do my distance calculations. I am using Microsoft Visual Studios 2008.
Homework Equations
The program is supposed to input the time in seconds and then use the formula
distance = (g * time2)/2 where g = 9.81
The Attempt at a Solution
Code:
#include <iostream>
using namespace std;
int main()
{
double time, distance;
cout << "Enter the time in seconds.\n";
cin >> time;
distance = (9.81*(time)^2)/2;
cout << "Distance traveled under free fall is "<< distance <<" meters per second.";
}
Last edited by a moderator: