Quote:
this gave me an error
Looks like you need to learn the basics of programming:
An error message tells you the reason of error and its position in code. Along with code, it is the most important information available to help you solve the problem.
You didn't showed either of them.
Quote:
//this gives unexpected number
This is not informative, about anything can lead to this comment.
Showing actual data and result would be more interesting.