I need help with this http://codepad.org/FNUci22s
I am posting the ling of code pad because it has a way to execute it, so long story short. I use two different functions seno, sen (both for sin). When using the printf and adressing both to compare results I get from the seno function the correct result(sin(45)=0.70710) but the moment I remove the other function from the printf i get "nan". Funcitons dont depend from each other.

5 Years
Discussion Span
Last Post by xikhari.some1behindu

The reason your program is behaving so unpredictably is because you are not initializing the variable res in your seno() function, nor are you initializing sin1 in your sen() function. Because you are using the values of these variables before initializing them, you are invoking undefined behavior. I could go on a long, detailed explanation of why it sometimes works, and why it sometimes doesn't work, but it's more important to simply fix the code.

When you declare sin1 and res, set them equal to 0.0 and it should work.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.