C++ Programming Code Examples
Learn C++ Language
Math Library Sine sin() Function in C++ Programming Language
Math Library Sine sin() Function in C++
Compute sine. Returns the sine of an angle of x radians. sin() function is a library function of cmath header, it is used to find the sine of the given number (angle), it accepts a number (x) and returns the sine of angle x radians.
Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).
This function is also overloaded in <complex> and <valarray> (see complex sin and valarray sin).
Syntax for Math sin() Function in C++
#include <cmath>
double sin (double x);
float sin (float x);
long double sin (long double x);
double sin (T x); // additional overloads for integral types
x
Value representing an angle expressed in radians. One radian is equivalent to 180/PI degrees.
Function returns double type value that is the sine of given angle x radians.
/* compute the sine of an angle of x radians by sin() math function code example. */
/* C++ sin() function returns sine of an angle given in radians. Angle is passed as an argument to sin(). */
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x = 0.439203, result;
result = sin(x);
cout << "sin(x) = " << result << endl;
double xDegrees = 90.0;
// converting degrees to radians
x = xDegrees*3.14159/180;
result = sin(x);
cout << "sin(x) = " << result << endl;
return 0;
}
This C++ program implements a "stack data" structure using two queue data structures. A stack data structure foolows the principle of LIFO(last element in first element out). Enter
When one 'function calls another', the calling function must "Send a Request" to the called function that would process it and return the necessary value, if any. C++ Language allows