
-----------------------------------
lei4848
Thu Mar 23, 2006 12:45 am

ASCII help
-----------------------------------
i am suppose to create a program where the user input the character "23" and the out put would be 23...i need serious help.

var car : char
var num : int
var cars : char
var nums : int

loop
get car
num:= ord(car)-48
nums:= ord(cars)
put num, nums
end loop

-----------------------------------
Andy
Thu Mar 23, 2006 1:46 am


-----------------------------------

var ch : string (1)
getch(ch)
put ord(ch)


-----------------------------------
chrispminis
Thu Mar 23, 2006 8:18 pm


-----------------------------------
That's not what he means Andy. 

You could do it;

var : str
get str 
put str


But I think you mean something like this...


var str : string
var number : int := 0

get str
for i : 1 .. length (str)
number *=  10
number += (ord (str (i)) - 48)
end for
put number
put number * 2

Not sure if the above works, but it should.

-----------------------------------
lei4848
Thu Mar 23, 2006 11:42 pm


-----------------------------------
thanks allot!!!

-----------------------------------
Andy
Thu Mar 23, 2006 11:45 pm


-----------------------------------
oh, he said character 23... i guess he menant characters 2 and 3
