Maker Pro
Maker Pro

C programming, function returning a garbage value

Luke Vassallo

Dec 10, 2014
33
Joined
Dec 10, 2014
Messages
33
Hello,

I am creating a program that will check for a number if a number is prime or not. However the function is returning a garbage number when I use local variables.(works fine with global though)

the code looks fine to me however I can't understand what's going wrong.

this is the function

Untitled.png
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Can you post the section of code that calls the function as well?
 

Luke Vassallo

Dec 10, 2014
33
Joined
Dec 10, 2014
Messages
33
I fixed the problem. It was expecting that after the function is executed it's value will be changed to either a 1 or a 0. But then I called the function to execute the code and use the returned value immediately.

I was thinking of it the wrong way, it actually returns a value and not change the function's value itself
 
Top