Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int main(){
- int i,n,j;
- double z;
- double suma=0;
- double cos;
- double fakt,gornji,donji,clan;
- do{
- printf("Molimo unesite vrednost za N-> ");
- scanf("%d",&n);
- } while (n<=0);
- do{
- printf("Molimo unesite vrednost za Z-> ");
- scanf("%lf",&z);
- } while (z<-1 || z>1);
- for(i=0; i<=n;i++){
- gornji=pow(-1,i)*pow(z,2*i);
- fakt=1.0;
- for(j=2; j<=(2*i);j++){
- fakt*=j;}
- clan=gornji/fakt;
- suma+=clan;
- }
- printf("\n\t-----------------------------");
- printf("\n\t cos(%lf)= %lf\n",z,suma);
- printf("\n\t-----------------------------\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement