Saying code is not correct in code coach even though outputs are same | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Saying code is not correct in code coach even though outputs are same

Language: C Code coach: EXTRA TERRESTRIAL #include<stdio.h> #include<string.h> int main() { char str[50]; scanf("%s",&str); int len,i; len=strlen(str); for(i=len;i>=0;i--){ printf("%c",str[i]); } return 0; } ANYONE TELL WHERE I DID THE MISTAKE

16th Jan 2021, 1:53 AM
SRI SIVA LAKSHMANA REDDY DWARAMPUDI
SRI SIVA LAKSHMANA REDDY DWARAMPUDI - avatar
1 Answer
+ 10
You are also displaying the NULL character which was there at the end of the string while printing the reverse string. Start your loop from (len-1) to fix it 👇 https://code.sololearn.com/cK7x49lnSNMK/?ref=app
16th Jan 2021, 2:06 AM
Arsenic
Arsenic - avatar