New Member FAQ | Forums | Earn Revenue | Distance Education | Help Topics | Admissions 2013
Awards & Gifts
 
Login Login    Register      

ArticlesPractice TestsAsk ExpertsQuestion PapersJobsUniversitiesCollegesCoursesSchools

Active Members
TodayLast 7 Daysmore...

Join our online Google+ community for Bloggers, Content Writers and Webmasters




A Program To Evaluate Sin(X) And Cos(X) Using Two Different Functions


Posted Date:     Total Responses: 0    Posted By: cihu   Member Level: Bronze   Points/Cash: 5   


/* CALCULATING THE VALUE OF SIN(x) AND COS(x)USING FORMULA */

#include
#include
#include

float sin_x(float ,int );
float cos_x(float ,int );
float power(float ,int );
float fact (int);


void main()
{
int k=0,n;
float x;
clrscr();
printf("\n Enter the value of n:\t");
scanf("%d",&n);
printf("\n The table is\n\n x(in degree) sinx\t\t cosx\n");
printf(" -------------------------------------\n");

while(k<=90) /*The value of k is in degree*/
{
x=k;
x=(x*(4*atan(1)))/180;
printf(" %4d\t\t%0.4f\t\t%0.4f\n",k,sin_x(x,n),cos_x(x,n));
k+=15;
}
printf(" -------------------------------------\n");
getch();
}


float sin_x(float x,int n)
{
float sum=0,f;
int i;
for(i=1;i<=n;i++)
{
f=fact(2*i-1);
sum+=power(-1,i+1)*power(x,2*i-1)/f;
}
if(sum<0)
sum=-sum;
return(sum);
}
float cos_x(float x,int n)
{
int i;
float f,sum=0;
for(i=1;i<=n;i++)
{
f=fact(2*i-2);
sum+=power(-1,i+1)*power(x,2*i-2)/f;
}
if(sum<0)
sum=-sum;
return(sum);
}
float fact(int n)
{
if(n==0 || n==1)
return 1;
else
return n*fact(n-1);
}
float power(float x,int n)
{
int i;
float k;
k=x;
if(!n)
return (1);
else
{
for(i=1;i k=k*x;
return (k);
}
}


Project Feedbacks

Author: Member Level: SilverRevenue Score: 1 out of 5
this is awesome program,i try it and its work propely.


Post Feedback
You must Sign In to post a feedback.
Next Project: Food And Feeding Habits Of Three Fresh Water Fishes
Previous Project: A "C" in unix which creates a server and client environment

Return to Project Index

Post New Project


Related Projects

Subscribe to Email
  • Get Jobs by Email
  • Forum posts by Email
  • Articles by Email
  • Online MembersVenkiteswaran.
    Nityananda Hazarika
    Bala
    shuhasini.l
    Vandana
    Muneer.police
    Hafeezur Rahman P
    Nilesh Patel
    sandhya
    M.K.Dan
    Laksh Porwal
    More...


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    AdSense Revenue Sharing sites   Advertise   Talk to Tony John
    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.