+ 2

Extra-Terrestrial code not working.

My output is exactly what is expected, as far as I can tell visually. But it is saying I am wrong. https://code.sololearn.com/c7X1SP54poD6/?ref=app

18th Mar 2022, 7:11 PM
Karl Marx
Karl Marx - avatar
13 Respostas
+ 3
You need to subtract 1 from i to make it work. Remember an array starts at 0 Try this: https://code.sololearn.com/c8TNoNk2PvdF/?ref=app
18th Mar 2022, 7:25 PM
Brain & Bones
Brain & Bones - avatar
+ 3
Hippopotomomonstrosesquippedaliophobia, the longest word in the world (37 characters). Debug 😎: while(i) printf("%c", word[--i]);
18th Mar 2022, 8:22 PM
Solo
Solo - avatar
+ 2
Nvm! I didn't see that you removed the = from <=
18th Mar 2022, 7:31 PM
Karl Marx
Karl Marx - avatar
+ 2
Thank you!
18th Mar 2022, 7:31 PM
Karl Marx
Karl Marx - avatar
+ 2
Change char word[20]; to char word[50];
18th Mar 2022, 7:37 PM
Brain & Bones
Brain & Bones - avatar
+ 1
I tried that, same result :(
18th Mar 2022, 7:29 PM
Karl Marx
Karl Marx - avatar
+ 1
It worked after that
18th Mar 2022, 7:31 PM
Karl Marx
Karl Marx - avatar
+ 1
Whoops, sorry, Yes i removed the <
18th Mar 2022, 7:32 PM
Brain & Bones
Brain & Bones - avatar
+ 1
Just did that lol
18th Mar 2022, 7:37 PM
Karl Marx
Karl Marx - avatar
+ 1
Thanks again haha
18th Mar 2022, 7:37 PM
Karl Marx
Karl Marx - avatar
+ 1
Lol, sure. It should work now Happy coding 😉
18th Mar 2022, 7:38 PM
Brain & Bones
Brain & Bones - avatar
+ 1
import java.util.*; public class Program { public static void main(String[] args) { String s,rev=""; Scanner sc=new Scanner(System.in); s=sc.nextLine(); s=s.trim(); int l=s.length (); for(int i=1;i<=l;i++) rev+=s.charAt(l-i); System.out.print(rev); } }
18th Mar 2022, 8:01 PM
Md Saif Ali
Md Saif Ali - avatar
0
2 of the 5 test cases are still red, but I can't see what they are. But the first two worked. Thanks
18th Mar 2022, 7:34 PM
Karl Marx
Karl Marx - avatar