Computer Science Canada

How to reverse word? help ASAP

Author:  chibitenshi_03 [ 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.

Author:  Paul [ Sun Feb 01, 2004 9:51 pm ]
Post 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

Author:  shorthair [ Sun Feb 01, 2004 9:53 pm ]
Post subject: 

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

Author:  Paul [ Sun Feb 01, 2004 9:54 pm ]
Post subject: 

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

Author:  chibitenshi_03 [ Sun Feb 01, 2004 9:57 pm ]
Post subject: 

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

Author:  chibitenshi_03 [ Sun Feb 01, 2004 10:01 pm ]
Post 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?

Author:  Paul [ Sun Feb 01, 2004 10:03 pm ]
Post 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.

Author:  we64 [ Sun Feb 01, 2004 10:12 pm ]
Post 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

Author:  Paul [ Sun Feb 01, 2004 10:14 pm ]
Post subject: 

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

Author:  we64 [ Sun Feb 01, 2004 10:21 pm ]
Post subject: 

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

Author:  shorthair [ Sun Feb 01, 2004 10:23 pm ]
Post 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

Author:  we64 [ Sun Feb 01, 2004 10:30 pm ]
Post subject: 

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

Author:  shorthair [ Sun Feb 01, 2004 10:33 pm ]
Post 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

Author:  jonos [ Sun Feb 01, 2004 10:37 pm ]
Post 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...

Author:  we64 [ Mon Feb 02, 2004 7:34 am ]
Post 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...

Author:  Paul [ Mon Feb 02, 2004 1:56 pm ]
Post subject: 

Theres always an easier way, we can always learn from people more experienced than us. Laughing

Author:  recneps [ Mon Feb 02, 2004 3:41 pm ]
Post subject: 

That's why we're here isnt it?

Author:  Andy [ Mon Feb 02, 2004 4:33 pm ]
Post subject: 

y dont u just change the original word by using a temporary char?


: