I must write a program in which the cursorian director to change the polar and on the contrary, with the use of the indicator, I write the following code But my function gives me the fault of division, I tried to do it without pointers and still does not send it to my number function, can someone help me modify my pointer code? I am new to C.
#include & lt; Stdio.h & gt; # Include & lt; Math.h> Zero Cart (Float * Radius, Float * Degree) {Float * x, * y, * radians; * Radian = (3.1415926535 9/180) * * degrees; * X = * radius * cos (* radians); * Y = * radius * sin (* radians); } Int main () {float radius, radians, degrees; Float x, y; Int M; Four c, p; Printf ("If you are converting Carterian to Polar, enter C"); Printf ("If you are converting polar to cartesian, enter p \ n"); Scanf ("% c", & amp; m); If (M == 'P') {printf ("Enter comma separated radius and angle \ n"); Scanf ("% f,% f", & amp; radius; & amp; degrees); Carriage (& amp; radius, & amp; degrees); Printf ("The Cartesian form is (% F,% F) \ n", X, Y); } And if (m == 'c') {printf ("Split value of x and y by commas = \ n"); Scanf ("% f,% f", & amp; x, & amp; y); Radius = sqrt (((x * x) + (y * y))); // find radius radian = come (y / x); // Finding angles in radian printing ("Polar form is (% F,% F) \ n", radius, radians); // angle is in radians) return 0; }
The first thing to note is in your cart:
zero cart (float * radius, float * degree) {float * x, * y, * radians; * Radian = (3.1415926535 9/180) * * degrees; * X = * radius * cos (* radians); * Y = * radius * sin (* radians); }
You have given the code named x
, y
and radians
, but they do not yet indicate
So when you distinguish them with * x
, * y
and * radians
such memory Which are not in existence, which will result in undefined behavior, possibly a split error.
I think your goal is to get the x
, y
and radians
to match those people , So that you should also underline them in the function.
No comments:
Post a Comment