OiO.lk Blog C# How to use sin, tan, cos, and sec in C program?
C#

How to use sin, tan, cos, and sec in C program?


I am making a calculator using the formula on this link:
http://cereference.com/book/surveying-and-transportation-engineering/simple-curves-or-circular-curves#sthash.qrD1VOm6.08csgYq9.dpbs

and

https://www.easycalculation.com/engineering/civil/highways-horizontal-curve.php

EDITED QUESTION!

So I used the math.h library in order to use the sin, tan, cos, and sec function but the answers are not right based on my formula… So to test, lets say I have an angle of 36 and a radius of 286… so the answer for the tangent (utangent) must be 92.927. and my next question is that how to use the sec function? I commented it because it wont compile… Also with tan,sin and cos.

#include<stdio.h>
#include<conio.h>
#include<math.h>


int main(){

double length, angle, radius, tangent, chord, midordinate, external, degree;
double pcurve, pintersection, ptangent;
double ulength, uangle, uradius, utangent, uchord, umidordinate, uexternal;
double pi;
double choice, choice2, given;

pi = 3.14159;

printf("Enter radius: ");
scanf("%lf",&radius);

printf("Enter angle: ");
scanf("%lf",&angle);

utangent = radius * (tan(angle/2)); 
uchord = 2*radius*(sin(angle/2));
umidordinate = radius - (radius*(cos(angle/2)));
//uexternal = radius * (sec(angle/2)) - radius;

printf("tangent = %lf\n",utangent);
printf("chord = %lf\n",uchord);
printf("ordinate = %lf\n",umidordinate);
//printf("%lf\n",uexternal);

getch();
return 0;
}



You need to sign in to view this answers

Exit mobile version