+ 3

Challenge 12: String Reversal with a Difference.

Write a program to input a string consisting of more than one word. Reverse the order of words in the string without altering the words, number of spaces, etc. If the string consists of exactly one word, display an error message. A word is any set of characters succeeded by a space.

19th Aug 2017, 7:16 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
14 Réponses
+ 9
Late by 2 minutes 😔. My try: https://code.sololearn.com/WFBwDwWlokEW/?ref=app
19th Aug 2017, 7:35 AM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 7
// with JavaScript function rev_sentence(sentence){ var tokens = sentence.trim().split(' '); if(tokens.length <= 1){ return 'error'; } return tokens.reverse().join(' '); } alert(rev_sentence(prompt('enter a string')));
19th Aug 2017, 7:30 AM
Burey
Burey - avatar
19th Aug 2017, 7:51 AM
ysraelcon
ysraelcon - avatar
+ 3
Guys...Help me out where i am missing . My code prints the reverse letter by letter.I am tried in C.Code Goes here.,, Amerandra challenge. void main(){ char[30],rev[30]; printf("Enter the string"); gets(str); strcpy(rev,str); strrev(rev); printf("reverse is %s", rev); } o/p : given string - solo learn The out put is = nrael olos.
19th Aug 2017, 12:23 PM
Bharath_Teki 🇮🇳
Bharath_Teki 🇮🇳 - avatar
+ 3
Here you go, amigo. Have a nice weekend. https://code.sololearn.com/W17T02MuReH3/#js
19th Aug 2017, 1:08 PM
Kustaa
+ 3
here is my try I know I am not good at coding but I try to do code in good way😊😊 https://code.sololearn.com/cYWEHK64RNDA/?ref=app
19th Aug 2017, 4:13 PM
GAWEN STEASY
GAWEN STEASY - avatar
19th Aug 2017, 10:34 AM
Vari93
Vari93 - avatar
19th Aug 2017, 11:03 AM
kamakshi
kamakshi - avatar
19th Aug 2017, 4:28 PM
David Ashton
David Ashton - avatar
19th Aug 2017, 7:58 AM
sayan chandra
sayan chandra - avatar
0
@Burey, could you attach a Sololearn code for this. I am too lazy to copy yours and test it in the Code Playground...😄😄😄
19th Aug 2017, 7:31 AM
Dragon Slayer Xavier
Dragon Slayer Xavier - avatar
20th Aug 2017, 6:21 PM
sayan chandra
sayan chandra - avatar
- 1
HERES THE NEW CHALLENGE... CHECK IT OUT FRIENDS https://www.sololearn.com/discuss/653982/?ref=app
24th Aug 2017, 6:53 PM
sayan chandra
sayan chandra - avatar