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

Username:   Password: 
 RegisterRegister   
 How to reverse word? help ASAP
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
chibitenshi_03




PostPosted: Sun Feb 01, 2004 9:46 pm   Post subject: How to reverse word? help ASAP

How do i make a program that ask the user to input a word and then output the word backwards like cow would be woc?

Time to enforce my rules, Topic Locked, also, subtracted bits from anyone I deem that was spamming. Oh, btw, I will be taking 100 bits, so people would remember, oh and the 100 bits are per post.
Sponsor
Sponsor
Sponsor
sponsor
Paul




PostPosted: Sun Feb 01, 2004 9:51 pm   Post subject: (No subject)

Use the "length" command.
code:

var word: string
put "Please enter word: "..
get word
for decreasing a:length(word)..1%runs a counted loop to the number of letters
put word(a)..%puts the word backwards, since the value a decreases.
end for
shorthair




PostPosted: Sun Feb 01, 2004 9:53 pm   Post subject: (No subject)

paulibians way is what were gonna use , i posted mine but i had it much more complicated , well done paul ,
Paul




PostPosted: Sun Feb 01, 2004 9:54 pm   Post subject: (No subject)

Um, if he is having trouble with this, lets try to help him with simple stuff eh?
chibitenshi_03




PostPosted: Sun Feb 01, 2004 9:57 pm   Post subject: (No subject)

lol thanks for the help i really appreciate it and also i'm a girl! ^^
chibitenshi_03




PostPosted: Sun Feb 01, 2004 10:01 pm   Post subject: (No subject)

The other part of the program is if a word is a palindrome i need to put this is a palindrome. How do i check if it is or not?
Paul




PostPosted: Sun Feb 01, 2004 10:03 pm   Post subject: (No subject)

Confused why does this remind me of my compsci class?

I'd use the above program to reverse the word, then use a variable to hold that word, and compare it to the original word. I hope you know how to do this, if not, just post.
we64




PostPosted: Sun Feb 01, 2004 10:12 pm   Post subject: (No subject)

this was one of my assigment... so here
code:

var word, backword : string := ""
put "Please enter a word: "
get word

for decreasing a : length (word) .. 1
    put word (a) ..
    backword := backword + word (a)
end for

if backword = word then
    put "This word is a palindrome."
else
    put "This word is not a palindrome."
end if
Paul




PostPosted: Sun Feb 01, 2004 10:14 pm   Post subject: (No subject)

Tony! how would Shantz like it if you did that to... um.. you know who.
we64




PostPosted: Sun Feb 01, 2004 10:21 pm   Post subject: (No subject)

who cares, shanz does not care... Laughing Laughing
shorthair




PostPosted: Sun Feb 01, 2004 10:23 pm   Post subject: (No subject)

I thikn everyone does those bad boy assignements , i remember them from way back when in grade 10 , i loved gradde 10 compsci , liek the first day we started i thought i was so cool made a simpsons quiz with just straight if statements , it rocked ,but we64 , thats like a carbon copy of mine , i did the exact same thing
we64




PostPosted: Sun Feb 01, 2004 10:30 pm   Post subject: (No subject)

shorthair, I never copyed yours, maybe we just had the same thought...
shorthair




PostPosted: Sun Feb 01, 2004 10:33 pm   Post subject: (No subject)

dude i wasnt implying that , i never posted mine , i just found it funny how they are the same , sorry if it sounded wrong
jonos




PostPosted: Sun Feb 01, 2004 10:37 pm   Post subject: (No subject)

im gonna kill my school or something, cause 90% of my class couldn't even use the length() function. you people are doing if statements on the first day, we didn't get to those until the middle of the semester. man, where do you people go to school, cause im gonna move...

anyways, paulbians is the best way, i also did a more complicated one, but...
we64




PostPosted: Mon Feb 02, 2004 7:34 am   Post subject: (No subject)

oh sorry shorthair, I didn't know. but I don't think there is a easier way than our idea to find out of palindrome. Also, many people did the same in my class, even the teacher, so it is common to have the same idea...
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 2  [ 18 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: