Program to find the sum of the sine series

Here is the program to find the Sinusoidal value of the given angle for the user defined accuracy. This is a fast, reliable and robust program, which uses no built in functions but a simple while loop and other math functions.

Logic: The program follows the mathematical sine series, where cosine of the entered radian angle x  is,

The program asks the user to enter the Angle x° . Also it asks for the number of iterations ‘n’ that the sine loop should iterate. As the iteration increases, the accuracy boosts up. After the desired loop, the resultant gets printed out. Similar algorithm can be set to find the Cosine value of the given number.

#include<stdio.h>
#include<math.h>
void main()
{
int i = 2, n, s = 1, x, pwr = 1, dr;
float nr = 1, x1, sum;
clrscr();
printf(“\n\n\t ENTER THE ANGLE…: “);
scanf(“%d”, &x);
x1 = 3.142 * (x / 180.0);
sum = x1;
printf(“\n\t ENTER THE NUMBER OF TERMS…: “);
scanf(“%d”, &n);
while(i <= n)
{
pwr = pwr + 2;
dr = dr * pwr * (pwr – 1);
sum = sum + (nr / dr) * s;
s = s * (-1);
nr = nr * x1 * x1;
i+= 2;
}
printf(“\n\t THE SUM OF THE SINE SERIES IS..: %0.3f”,sum);
getch();
}
Download exe and source code here.

Editorial Team
Editorial Team

We are a group of young techies trying to provide the best study material for all Electronic and Computer science students. We are publishing Microcontroller projects, Basic Electronics, Digital Electronics, Computer projects and also c/c++, java programs.

6 thoughts on “Program to find the sum of the sine series

  1. Sir very nice program. But if u write i+=2 then only half of the terms will add to sum. I guess u need to correct this. It is i++ not i+=2.

  2. no you are wrong. i+=2 is only correct because sine series is x-x3/3!+x5/5!-x7/7!+……

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the latest updates on your inbox

Be the first to receive the latest updates from Codesdoc by signing up to our email subscription.

    StudentProjects.in