Hello,

http://www.daniweb.com/software-development/java/threads/223488

I need C code for a problem in given link above. I tried to convert it to C code but couldn't do it, i'm kinda beginner. I guess it's easy problem for pro programmers so i really appreciate if you can help me out.

Recommended Answers

All 4 Replies

i'm kinda beginner.

It shows. Beginners rarely bother to read the Member Rules nor the sticky post Read This Before Posting before asking a question.

Well actually i have read it.if you are talking about "don't give away code" section,okay. Thing is, i need it for tomorrow evening, it's homework and i know so little about C right now. I have final exam 2 weeks later, just bought some books and stuff and will work for it but now i don't have time to learn things and do it. sorry if it's against posting rules.

No, I'm talking about the Do provide evidence of having done some work yourself if posting questions from schoolwork assignments section.

You must be under the mistaken impression we are a homework service. We are not. You do the work, we help solve problems - in a teaching manner, not a rewrite it for me manner.

>>Thing is, i need it for tomorrow evening
As the saying goes, "Poor Planning On Your Part Does Not Constitute An Emergency On Our Part".

Sorry about that than but why so serious ? :D Anyway, i managed to solve my first question but now i have another one. Listened your advice and I did some work. The problem is I don't know how to terminate series like it is asked in problem. Can you help me out now ?

[IMG]http://img193.imageshack.us/img193/2381/adszxmz.jpg[/IMG]

Uploaded with ImageShack.us

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

static double factoriel(int a){
    double result = 1.0;
    while (a > 0) {
        result*=a;
        a--;
    }
    return result;
}


int main(void){ 

double total=0.0;
double temp=0.0;
float x;
printf("Please give me the x value: ");
scanf("%f",&x);
x = x *3.14/180;

    for(int i=0;true;i++){
            total+=  pow((-1),i) * pow(x,((i*2)+1)) / factoriel((i*2)+1);
              
            
            
                           
            
            if(pow((-1),i) * pow(x,((i*2)+1)) / factoriel((i*2)+1)/total<0.001){
                                 printf("%d",i);
            break;
            }
                          
                          

         }
         printf("\nSin%f: %f \n",x,total);
    system("pause");
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.