Thursday, August 11, 2011

Whats the problem with this beginners c code?

Daniel B is right. If you use sum=1 then you are assigning the value to ' sum ' which is now 1 . Anything other than zero and null is true inside the if so all the statements will get executed. Just change = to == .

No comments:

Post a Comment