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

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

The program asks the user to enter the Angle x° . Also it asks for the number of iterations ‘n’ that the cosine 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 Sine value of the given number.

#include<stdio.h>

#include<math.h>

void main()

{

float pow = 2.0, nr, dr = 1.0, x1, sum;

int i = 1,n,s = -1,x;

clrscr();

printf(“\n\n\t ENTER THE ANGLE…: “);

scanf(“%d”, &x);

x1 = 3.142 * (x / 180.0);

sum = 1.0;

nr = x1*x1;

printf(“\n\t ENTER THE NUMBER OF TERMS…: “);

scanf(“%d”,&n);

while(i<=n)

{

dr = dr * pow * (pow – 1.0);

sum = sum + (nr / (dr * s));

s = s * (-1);

pow = pow + 2.0;

nr = nr * x1 * x1;

i++;

}

printf(“\n\t THE SUM OF THE COS SERIES IS..: %0.3f”, sum);

getch();

}

Download exe and source code here.

Description :

Email: |

8951
algorithm
array
ASM program
binary tree
C/C++
C/C++ Programms
c graphics
c interview question
class
cpp
c program
c programs
C Programs
Data structure
download
engineering questions
free
frequently asked interview questions
Graphics
HDL
interview questions and answers
it interview questions
Java
Java program
Keyboard Interface
lab programs
linked list
Linked Lists
Microcontroller
microprocessor
program
programs
questions for an interview
Queue
source code
Source Codes
stack
Stepper motor
templates
top interview questions
verilog
Verilog program
Verilog programs
vlsi

This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.

#Home #Sitemap #Resources #Terms of Use

Copyright©2012 electrofriends.com All Rights Reserved

Contact:info@electrofriends.com