hello,
i'm currently in a calc class and the most recent assigned homework requires a bunch of calculations that are very basic yet very repetitive. I'm wanting to write a program in c to perform these calculations using a few nested loops, the only problem is that some of them require sin and cos, which i'm not familiar with in c... are these in any way incorporated into the math.h library? thanks for any help!
User Profile
Collapse
-
please ignore the code from my previous post, i typed it in a rush and realized it had many glaring syntax errors, try this one instead...
...Code:#include<stdio.h> void pi(int n, double *pi_value, int *iterations); //declare function int main (void) { int n; //number of terms int iterations = 0; //number of actual loop iterations in pi -
so here is what i've come up with...
it seems to me like it should execute correctly, but somewhere something is causing my output to be bogus large numbers; however, it will compile... does anyone see my error?
any help will be appreciated!
...Code:#include<stdio.h> void pi(int n, double *pi_value, int *iterations); //declare function int main (void) { int n;Leave a comment:
-
haha yes i've been told to stay away from scanf, but for this particular program that is what is supposed to be used... don't ask me
and what i have there does run and execute fine, its getting what I have there to loop that is giving me problems.
i.e. i want to add another loop outside of my current for loop, that executes just after my first printf, and then will continue looping the entire program until solely a period...Leave a comment:
-
i'll give that a whirl, i see what you're getting at
i'm coding in standard C
i appreciate the help!Leave a comment:
-
my bad on the +'s and -'s that was simply a typo...
so if i was to write a for loop something like
int PI;
int n; //number of iterations
int den_val; //denominator value
for(PI = 0; n > den_val; PI += den_val) {
/*code*/
}
and assuming that is correct, i'm still a little confused on how to incorporate the equation into the loop. I understand the 4 - 4/3...Leave a comment:
-
nested loop
one more quick question, this isn't complicated but somehow i'm causing infinnite loop when i attempt it. given the following code...
starting after the first printf i need everything else to loop, any ideas using a nested loop? thanks!
...Code:#inclde<stdio.h> #define START_CHAR ' ' #define END_CHAR '.' int check_sum(int sum); int main(void) { int char_code,sum,checksum,x;Last edited by Niheel; Oct 22 '06, 10:49 PM. -
PI equation in C
Hello All,
i'm currently working on a program wich asks the user to input an integer value of "n" to determine what value of the denominator in an equation for PI to work to.
this is written in c, and I have all the basic input, output, function calls etc; however, i'm relatively new to c and i'm a bit confused on how to turn the equation below into a c expression with variable input.
PI = 4(1...
No activity results to display
Show More
Leave a comment: