Sin() Function in C

Learn via video course
FREE
View all courses
C++ Course: Learn the Essentials
C++ Course: Learn the Essentials
by Prateek Narang
1000
5
Start Learning
C++ Course: Learn the Essentials
C++ Course: Learn the Essentials
by Prateek Narang
1000
5
Start Learning
Topics Covered

Overview

The sine (sin, in short) function in mathematics is a trigonometric function of an angle. In the C programming language, the <math.h> header file provides us with the sin() function. This function allows us to calculate the sin value of any given angle (in radians).

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Syntax of Sin() Function in C

Following is the syntax of the sin function in C.

Here x is the angle in radians.

Parameters of Sin() Function in C

The sin function takes only one parameter -

  • x: double

Here x is the angle in radians (not degrees)

Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

Return value of Sin() function in C

Return type: double

The sin function in C returns one value, the sine of an angle x. The return value ranges between -1 to +1, both inclusive.

Exceptions of Sin() Function in C

There are no exceptions of the sin function in C.

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Example

Let us take a simple example to get an overview of the sin function in C.

Output of the above program:

In the above example, we imported the <math.h> header file so that we could use the sin() function and the M_PI constant (M_PI stores the value of pi). We created a variable x to store the value of an angle. Finally, we used sin(x) to calculate the sine of the variable x and then printed the value it returned.

What is sin() Function in C?

The sin() function takes an angle as an argument and returns the ratio of the length of the opposite side (or side opposite to the angle) of a right triangle to the length of its hypotenuse.

What is sin Function in C

sin(x) = opposite side (o) / hypotenuse (h)

Here is what the graph of the sin() function looks like: what io graph of the sin

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

More Examples

Example 1: Calculating sine of Zero, Positive, and Negative values

Output of the above example:

In this example, we used the sin() function to calculate the sine value of three different numbers - zero, a negative number, and a positive number. We used the printf() function to print out the values returned by the sin() function.

Example 2: Calculating sin() of an Angle in Degrees

If we have an angle in degrees, we can convert it into radians so that we could use the angle's value as an argument in the sin() function. We know that PI radians are equal to 180 degrees. So, we can use basic mathematics to convert degrees into radians.

Output of the above example:

In this example, we had an angle in degrees instead of radians. So, we converted degrees into radians and then used the angle in radians to calculate the sine value.

Conclusion

  • The sine function is a trigonometric function of angles.
  • The sin() function in C is used to calculate the sine value of any angle in radians.
  • The sin() function takes only one argument, the value of the angle.
  • The value returned by the sin() function ranges between -1 to +1 both inclusive.