Thursday, April 25, 2024
HomejQueryC++ sin() operate

C++ sin() operate [3 Examples]


The sin operate in C++

  • sin() is the built-in operate in C++
  • This operate is outlined within the <cmath> library – it’s a must to embody this within the header with a view to use it.
  • The sin() operate takes one argument i.e. a quantity which is angle and it returns the sine of angle x radians.
  • The return worth is of double kind i.e. sine of the given argument x (radians)

Syntax of sin() operate

sin(x);

An instance of utilizing sin() operate

Within the first instance, we merely present a worth to the sin() operate and assign the return worth to a double-type variable. Then we displayed the end result as follows:



Consequence:

CPP-sine

Taking consumer enter for sin()

As you run this C++ program, it asks you to enter the angle given in radians. Then sin() operate is used to get the sine and we’ll show the end result:



Pattern end result:

CPP-sine-rad

Utilizing detrimental worth instance

For this instance, we assigned a detrimental worth to the sin() operate.



Output:

 


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments