STring Help
Author |
Message |
mallardrocker
|
Posted: Wed Oct 03, 2007 7:30 pm Post subject: STring Help |
|
|
QUESTION #5
Write a program that will get a string from the user.
First check to see if the string contains an odd number of characters. If it does, add a space to the end of it (by using string concatenation).
Now, output the first half of the string to screen.
that is the question i have to do, i cant do it, any help woul dbe appreciated thanks |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
CodeMonkey2000
|
Posted: Wed Oct 03, 2007 7:33 pm Post subject: RE:STring Help |
|
|
Sigh, the length() function returns the number of characters in the string. x mod y will give you the the remainder between x and y. What you want to check is whether or not length(myString) mod 2 =0. |
|
|
|
|
![](images/spacer.gif) |
mallardrocker
|
Posted: Wed Oct 03, 2007 10:41 pm Post subject: Re: STring Help |
|
|
what do u mean the lenght function you mean,
length (word) |
|
|
|
|
![](images/spacer.gif) |
Euphoracle
![](http://compsci.ca/v3/uploads/user_avatars/11170373664bf5f25f636f1.png)
|
Posted: Thu Oct 04, 2007 7:03 am Post subject: RE:STring Help |
|
|
I haven't used turing in a long time, but isn't it str.Length() |
|
|
|
|
![](images/spacer.gif) |
CodeMonkey2000
|
Posted: Thu Oct 04, 2007 12:43 pm Post subject: RE:STring Help |
|
|
Not in my version.
And yes, I do mean length(word); word being a string variable. |
|
|
|
|
![](images/spacer.gif) |
|
|