I have tried to deal with class variables but I received weird output
the code is here and below it is the output
as u can see in the output it just repeats them and did not sum them up
and returns the summation value.
any idea?
Your problem has nothing to do with class variables. The gets() method
returns a *string* not a number. When the user enters some characters
and then hits return, gets() will return something like this:
10\n
The '\n' is the newline character that was entered when the return key
was pressed. The second string will look something like:
20\n
When you add those strings together, you get:
"10\n20\n"
Then when you use puts to output the string, your computer screen
converts the '\n' characters to newlines, which produces: