Archived

This topic is now archived and is closed to further replies.

brassfish89

sin not right?

Recommended Posts

Ok, im making a calculator program and it's saying that sin(45) is: 0.850904 when the windows calculator says it is: 0.70710678118654752440084436210485 here is the code:
  
#include <iostream>
#include <stdlib.h>
#include <math.h>

int main(int argc, char *argv[])
{
  while(1)
  {
    int input=0;
    double number=0.0f;
    double answer=0.0f;
    cout<<"What would you like to calculate?\n"
    "1. sine\n"
    "2. cosine\n"
    "3. tangent\n"
    "4. arcsine\n"
    "5. arccosine\n"
    "6. arctangent\n"
    "7. square root\n";
    cin>>input;
    cout<<"What number do you want to perform the operation on? ";
    cin>>number;
    switch(input)
    {
        case 1:
            answer=sin(number);
        break;
        case 2:
            answer=cos(number);
        break;
        case 3:
            answer=tan(number);
        break;
        case 4:
            answer=asin(number);
        break;
        case 5:
            answer=acos(number);
        break;
        case 6:
            answer=atan(number);
        break;
        case 7:
            answer=sqrt(number);
    }
    cout<<"Answer: "<<answer<<endl;
    cout<<"Press 0 or 1 to continue\n";
    cin>>input;
    if(input==0)
        break;
    system("cls");
  }
  cin.get();
  return 0;
}
   
thx brassfish edit: put code tags instead of source tags
doh, nuts. Mmmm... donuts My website [edited by - brassfish89 on April 29, 2003 8:31:57 PM]

Share this post


Link to post
Share on other sites