Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 ASCII help
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
lei4848




PostPosted: Thu Mar 23, 2006 12:45 am   Post subject: 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
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Thu Mar 23, 2006 1:46 am   Post subject: (No subject)

code:

var ch : string (1)
getch(ch)
put ord(ch)
chrispminis




PostPosted: Thu Mar 23, 2006 8:18 pm   Post subject: (No subject)

That's not what he means Andy.

You could do it;

code:
var : str
get str
put str


But I think you mean something like this...


code:
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




PostPosted: Thu Mar 23, 2006 11:42 pm   Post subject: (No subject)

thanks allot!!!
Andy




PostPosted: Thu Mar 23, 2006 11:45 pm   Post subject: (No subject)

oh, he said character 23... i guess he menant characters 2 and 3
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: