Maker Pro
Maker Pro

C programming, function returning a garbage value

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
 
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