C++ not displaying Pi right.

Status
Not open for further replies.

theopfor

In Runtime
Messages
173
Location
Right behind you
I decided to write my very first USEFUL C++ program. I am trying to convert an angle to a radian. When I put 180 into the program when it prompts for an angle I put in 180 because it should shoot right out pi but instead is puts out 3.

Code:
#include <iostream>

using namespace std;

int main()
{
    cout << "Insert angle please: ";
    int angle=567;
    cin>>angle;
    angle=angle*3.1415926535897932384626433832795/180; //this will make the angle a radian but it has trouble
    cout<<"The radians are: "<<angle<<endl; 
    return 0;
}

Please note that I am only a begginer where I only know cout, endl, cin, functions, int, and comments.
 
Oh. Upsetting how simple that was but I am learning. Thanks. The default variable for angle was just so I would know if there was an error or not. But what is the difference between integers, doubles, and floating point variables?
 
Status
Not open for further replies.
Back
Top Bottom