|
From: shan c. <sha...@ya...> - 2008-01-19 06:38:21
|
Hey dude there were lots of bugs in your code,I assume that they were just copying error so I am correcting only the logical error in your code.
First of all sine and cosine takes radians as its parameter so "20" which you were thinking as degree code took it as radian so proper conversion is needed.
here is my code:
#include<cmath>
#include<iostream>
#define PI 3.1415926535
using namespace std;
int main()
{
double temp1;
double temp2;
double angle;
cout<<"Enter the angles in degrees";
cin>>angle;
angle=(angle*PI)/180;//In c++ sine and cosine functions takes parameters in radians.
//So we convert angles to radians.
temp1 = cos(angle);//Calculates cos of angle.
temp2 = sin(angle);//Calculates sine of angle
cout <<endl<<"cosine of"<<angle*180/PI<<":"<<temp1;
cout<<endl<<"sine of"<<angle*180/PI<<":"<<temp2;
cin.get();
return 1;
}
I compiled in dev c++.This link might be helpful to u:
http://www.macs.hw.ac.uk/~pjbk/pathways/cpp1/node121.html#ex.sin.table
I think you are a novice in c++,i am not an expert though but I can be of your help.
Plz feel free to contact me for any help.
Brad Woosley <c_b...@ya...> wrote: I attempted to make a program that will use the sine and cosine of a number, but is seams that the #s were switched. Can anyone tell me if I did something wrong. Bellow is the code relevant to this.
#include <cmath>
I also tried using #include <math.h> but it did the same thing
double temp1;
double temp2
double angle
temp1 = cos(angle);
temp2 = sin(angle);
cout << temp1 << " " << temp 2;
I run it and I get for an angle of 20
cosine = 0,408082
sine = 0.912954
I plug it into a calculator and I get for the same angle
cosine = .939692
sine = 0.342020
_______
visit utb.zoomshare.com to read my different stories that I have written.
"If at first the idea is not absurd, there is no hope for it"
-Albert Einstein
---------------------------------
Never miss a thing. Make Yahoo your homepage. -------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
Dev-cpp-users mailing list
Dev...@li...
TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
hey man go rocking
---------------------------------
Get the freedom to save as many mails as you wish. Click here to know how. |