Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define PI 3.14159265
- #define EPS 0.001
- int main (int argc, char** argv) {
- double xStepen, x, gornji, kosinus=0;
- long int donji;
- int znak=-1, faktorijel=0, i;
- printf("ugao u stepenima: ");
- scanf("%lf", &xStepen);
- for (i=1; ;i++) { //
- if ((xStepen - i*360) < 0) break; //sredjuje
- } //periodicnost
- if (i > 1) xStepen -= (i-1)*360; //
- x = (PI/180)*xStepen;
- kosinus += 1;
- do {
- gornji=x;
- donji=1;
- faktorijel+=2;
- for (i=1; i < faktorijel; i++) {
- gornji *= x; //stepenovanje brojioca
- }
- for (i=2; i<=faktorijel; i++) {
- donji *= i; //faktorijelisanje imenioca
- }
- kosinus += znak * (gornji/donji);
- znak = -znak;
- } while (gornji/donji > EPS);
- printf("%.3lf", kosinus);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement