code,calculates,values,basic,trigonometric,fu
Quick Search for: in language:   
code,calculates,values,basic,trigonometric,fu
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 326,796 lines
 Jobs: 886 postings

 

You are in:

 
Login


Latest Code Ticker for C/ C++
Click here to see a screenshot of this code!SOCommunicator (Client/Server Chat)
By Stephan Gramlich on 2/28

(Screen Shot)

Script Language, small but powerful
By Eric Hodges on 2/27


hangman 1.0
By kyle burmark on 2/27


MasterGraphicEx
By Dan Anderson on 2/27


secant
By Anish Chapagain on 2/27


Click here to see a screenshot of this code!game of grid
By patel chirag v on 2/27

(Screen Shot)

Click here to see a screenshot of this code!game of othello
By patel chirag v on 2/27

(Screen Shot)

Enable / Disable Start Menu
By David Rodrigues Cardeiro on 2/26


Show / Hide Start Button
By David Rodrigues Cardeiro on 2/26


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 

 
 

   

Trig Calculator

Print
Email
 
VB icon
Submitted on: 2/18/2002 11:41:58 PM
By: Luchezar Abbott  
Level: Intermediate
User Rating: Unrated
Compatibility:C++ (general)

Users have accessed this code 273 times.
 

(About the author)
 
     The code calculates the values of the basic trigonometric functions: sine, cosine, tangent, cosecant, secant, cotangent.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: Trig Calculator
// Description:The code calculates the v
//     alues of the basic trigonometric functio
//     ns: sine, cosine, tangent, cosecant, sec
//     ant, cotangent.
// By: Luchezar Abbott
//
// Inputs:The arguments (variables) for 
//     the functions and integers used for sele
//     cting an option
//
// Returns:The values of the trig functi
//     ons
//
// Side Effects:Inputing characters when
//     asked for numbers. It usually starts loo
//     ping everything or freezes the program
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/xq/ASP/txtCod
//     eId.3327/lngWId.3/qx/vb/scripts/ShowCode
//     .htm//for details.//**************************************
//     

// TRIG CALCULATOR
//Calculates the values of trigonometric
//     functions
//By Luchezar Abbott
//If you want to use any parts of this c
//     ode, please e-mail me at lucho33@juno.co
//     m with an explanation 
#include <iostream.h>
#include <math.h>
#define PI 3.141592654
void sine (double x)
    { 
    	double sine_result;
    sine_result= sin (x);
    cout<<sine_result<<'\n';
}

void cosine (double x) { double cosine_result; cosine_result= cos (x); cout<<cosine_result<<'\n'; }
void tangent (double x) { double tangent_result; tangent_result= tan (x); cout<<tangent_result<<'\n'; }
void cosecant (double x) { double csc_result; csc_result= 1/(sin (x)); cout<<csc_result<<'\n'; }
void secant (double x) { double secant_result; secant_result= 1/(cos (x)); cout<<secant_result<<'\n'; }
void cotangent (double x) { double cot_result; cot_result= sin (x); cout<<cot_result<<'\n'; }
void radians (){ int rad_function; double x; cout<<"Enter your argument (in radians): \t"; cin>>x; cout<<"Select one of the following functions: \n"; cout<<"\t 1. SINE \n"; cout<<"\t 2. COSINE \n"; cout<<"\t 3. TANGENT \n"; cout<<"\t 4. COSECANT \n"; cout<<"\t 5. SECANT \n"; cout<<"\t 6. COTANGENT \n"; cin>>rad_function; switch (rad_function) { case 1: sine(x); break; case 2: cosine(x); break; case 3: tangent(x); break; case 4: cosecant(x); break; case 5: secant(x); break; case 6: cotangent(x); break; default: cout<<"INVALID FUCTION: Go back to the list and select a valid function. \n"; } } void degrees (){ int deg_function; double deg_arg; double x; cout<<"Select one of the following functions: \n"; cout<<"\t 1. SINE \n"; cout<<"\t 2. COSINE \n"; cout<<"\t 3. TANGENT \n"; cout<<"\t 4. COSECANT \n"; cout<<"\t 5. SECANT \n"; cout<<"\t 6. COTANGENT \n"; cin>>deg_function; switch (deg_function) { case 1: sine(x); break; case 2: cosine(x); break; case 3: tangent(x); break; case 4: cosecant(x); break; case 5: secant(x); break; case 6: cotangent(x); break; default: cout<<"INVALID FUCTION: Go back to the list and select a valid function. \n"; } cout<<"Enter your argument (in degrees is decimal form): \n"; cin>>deg_arg; x=deg_arg*PI/180; } void main() { int mode; do { cout<<"Set your mode: \n"; cout<<"\t 1. Radians\n"; cout<<"\t 2. Degrees\n"; cin>>mode; if (mode==1) { radians(); }
else if (mode==2){ degrees (); }
else { cout<<"INVALID MODE: Choose 1 or 2! \n"; }
}while (mode!=1 && mode!=2);
}


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The codewith your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
2/19/2002 5:22:43 PM:scott
sorry mna, i'm not putting your code 
down, but you've declared a char 
variable for the option menu, but in 
the wsitch statement, youve 
used
switch .....
.
.
case 
3:
.
.
case 4:
.
etc
it should 
be in character format ie:
case 
'1':
case '2':
etc
without this your 
program returns the default case each 
time
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.