I would recommend using literals instead of char ordinal values, for instance, instead of (ch>=48&&ch<=57), you can use ( ch >= '0' && ch <= '9' ), the value remains the same, but it is easier to read the code and you won't get lost in it.
And lastly, I assume that if you get ch == 13 then you want to return(num), for that you are using "do {} while(1)" loop, but I don't understand why, you can just set it as "while (ch != 13) {}", in that scenario you won't have to break out of the cycle and be sure your number is returned.