Finding cosine value in c language.
Programme to find cosine value.
Hello friends this is the simple code for finding the cos values in c language.C language provide the inbuilt cos function which is available in math.h header file and use in finding the cosine value.The following programme fine the cosine value starting from 0 to 180 degree.
Following method has used in finding the cosine value.
- Take the integer angle variable.
- Assign it's initial value to zero.
- Run the iteration till the maximum value of 180 degree.
- Inside the iteration convert degree into radian.
- Find the cos value of converted value using cos() function.
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI 3.1416
#define MAX 180
void main()
{
clrscr();
int angle;
float x,y;
angle=0;
printf("Angle Cos(angle)\n \n");
while(angle<=MAX)
{
x=(PI/MAX)*angle;
y=cos(x);
printf("%15d %13.4f\n",angle,y);
angle=angle+10;
}
getch();
}
Finding cosine value in c language.
Reviewed by Deepak kumar soni
on
December 24, 2018
Rating:
Appreciative.
ReplyDelete