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.

Recommended Answers

All 2 Replies

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.

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.