What is the proper way to involve trig functions?

Hello, I am writing a code that will estimate an objects distance when launched from a canon at a set speed, with variable angle of canon and the what distanced the ball traveled at a specific time.

This is my code:
//File: Trajectory distance. cpp
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
const float g = 9.8, v = 80; // g is the force of gravity and Vo is the intial speed in meters/sec the object is launched.
int t; // t would be the time so that you would know how far it traveled in that many secs.
float y, a, x; // a is the angle the canon is set.

cout << "Enter canons angle: ";
cin >> a;
cout << "Enter the time: ";
cin >> t;

y = sin (a);

x = v * y * t - 0.5 * g * t^2;

cout << "The objects distance is: " << x << endl;

return 0;
}

When I give the equation for (x) an error is under the (v) saying that I need to add an integral or enum type. I am not understanding what they mean by that so can anyone please give me a better understand in how I need to approach this?
t^2 does not do what you think its doing - ^ is the bitwise exclusive or (XOR) operator (integral types).

1
2
//x = v * y * t - 0.5 * g * t^2;
x = v * y * t - 0.5 * g * t*t ;
Wow, it's a shame how little things like that can cause a big issue.
Topic archived. No new replies allowed.