C Program to Use Trigonometric Functions

C programming, you can use trigonometric functions from the <math.h> header to perform various trigonometric calculations. Here’s a simple program that demonstrates the use of some common trigonometric functions.

sin( ) :

#include<stdio.h>
#include<math.h>
int main()
{
double result,x;
printf(“Enter the Value : “);
scanf(“%lf”,&x);
result=sin(x);
printf(“The sin() of %lf is %lf\n”,x,result);
return 0;
}

Output :

cos( ) :

#include<stdio.h>
#include<math.h>
int main()
{
double result,x;
printf(“Enter the Value : “);
scanf(“%lf”,&x);
result=cos(x);
printf(“The cosine() of %lf is %lf\n”,x,result);
return 0;
}

Output :

tan( ) :

#include<stdio.h>
#include<math.h>
int main()
{
double result,x;
printf(“Enter the Value : “);
scanf(“%lf”,&x);
result=tan(x);
printf(“The tan of %lf is %lf\n”,x,result);
return 0;
}

Output :

abs( ) :

#include<stdio.h>
#include<math.h>
int main()
{
int result,x;
printf(“Enter the Value : “);
scanf(“%d”,&x);
result=abs(x);
printf(“The Absolute value of %d is %d\n”,x,result);
return 0;
}

Output :

sqrt( ) :

#include<stdio.h>
#include<math.h>
int main()
{
double result,x;
printf(“Enter the Value : “);
scanf(“%lf”,&x);
result=sqrt(x);
printf(“The square root of %lf is %lf.\n”,x,result);
return 0;
}

Output :

log( ) :

#include<stdio.h>
#include<math.h>
int main()
{
double result,x;
printf(“Enter the Value : “);
scanf(“%lf”,&x);
result=log(x);
printf(“The natural log of %lf is %lf.\n”,x,result);
return 0;
}

Output :

Leave a Comment

Your email address will not be published.

Shopping Basket
Verified by MonsterInsights