I am making a calculator for 8th grade geometry class. We are learning about trigonometric ratios. My problem is, I got the whole program written, and then I realized that my sines and cosines should be getting decimals. I realize the problem is because I'm using the wrong variable type. I checked it, and I'm using floats. I think the problem is my funtion is returning ints. Criticism welcome as long as it has to do with my problem. I'm new at this programming thing, just started 25 minutes ago in fact, so it's gonna be sloppy.
Edit-----> Lol I just figured it out. I was using an int type function lol! I'm stupid!I'm stupid!I'm stupid!I'm stupid!
Source Code ------->
Code:
// Trigonometric Ratios Helper.cpp : Defines the entry point for the console application.
// By { A nanny Mouse! }
#include "stdafx.h"
#include <iostream> //Input Output
using namespace std; //No idea but it looks cool =/
int sine ( float b, float c );
int main()
{
float Leglength1;
float Leglength2;
float hypotenuse;
float sinea;
float cosa;
float tana;
float tanb;
cout<<" {Blocked for forum use}'s Amazing Trigonometric Ratio Helper!"<<"\n";
cout<<" B" <<"\n";
cout<<" /|" <<"\n";
cout<<" / |" <<"\n";
cout<<" Hyp / |Leg2" <<"\n";
cout<<" / |" <<"\n";
cout<<" A----C" <<"\n";
cout<<" Leg1" <<"\n";
cout<<"Please enter the length of a leg: ";
cin>> Leglength1;
cin.ignore();
cout<<"Please enter the length of the other leg: ";
cin>> Leglength2;
cin.ignore();
cout<<"Now the tricky part, enter the hypotenuse: ";
cin>> hypotenuse;
cin.ignore();
sinea = sine(Leglength2, hypotenuse);
cout<<" B" <<"\n";
cout<<" /|" <<"\n";
cout<<" / |" <<"\n";
cout<<" " << hypotenuse << " / |"<< Leglength2 <<"\n";
cout<<" / |" <<"\n";
cout<<" A----C" <<"\n";
cout<<" "<< Leglength1 <<" " << "\n";
cout<<"Sin A: "<< sinea <<"\n";
cin.get();
}
int sine ( float b, float c )
{
return b /= c;
}