The Qs are below, and as u can c ive started both Qs but dunno how to finish them ..any help would appreciated thanks
1) C programme for iinverse of cos-rule
where cosA = (b^2+c^2-a^2)/2bc
The Qs are below, and as u can c ive started both Qs but dunno how to finish them ..any help would appreciated thanks
1) C programme for iinverse of cos-rule
where cosA = (b^2+c^2-a^2)/2bc
Last edited by jack0; 04-27-2010 at 01:50 AM.
Can you be a little more specific in regard to the second question? What exactly are you having trouble doing?
As for the first, it is pretty difficult to compute acosine(x) manually if that is what you are trying to do. I believe there are already functions in math.h that do that for you.
In fact there is a function in math.h:
double acos(double x). That should do it.
so do i need to rewrite the whole program ?
Well I dont understand why you are reinventing the wheel here. There is a function acos() that computes what you want to compute in part 1, and it probably does it better than you could. Just #include <math.h> and call that function in your main code where you need to calculate acosine.
As for part 2 one thing that I would note is that factorial is not a floating pointer value but rather an integer. Approximations of factorials like gamma functions do exist indeed. I am not sure what you are trying to compute there.
I personally don't know enough trigonometry to calculate acosine manually, although someone else here may be able to provide a solution to that. However, it's most likely going to be the solution already available to you through the math library.
Do you always have to include #include <math.h> if your using a math function?
I know I am always suppose to because it is the 'correct' thing to do but I have ran my program by accident (it had sqrt() and pow() in it) and the output was correct without it... I am just curious...
You only have to include it if you are using a function declared in it. Including a library file is literally copying and pasting it's contents into your source code. For a listing of the functions included in math.h or any other standard header file for that reason just google its name or open it in your C library and see what's inside it.
Matt, for a long time, compilers have been "smart" about adding in certain header definitions, automatically. Even Turbo C v1.01 does it. < HA! >
But they won't do it for every definition you might need, so doing it manually is by far the better solution. Actually, Turbo C trips itself up on loading floating point sometimes, even when you include math.h. < EEK! >