0
Why Coach Section is not working?
Coach section is not working because the below program's output is correct same as expected output but it not accepting. I also have screenShot but unable to attach it. The problem is of Extra-Terestials The program print the reverse order of string. #include <stdio.h> #include<stdlib.h> int main() { char letter[50]=""; int i; scanf("%s",letter); for(i=49; i>=0; i--) { printf("%c",letter[i]); } return 0; }
12 Respuestas
+ 4
PRINCE KUMAR , a string is defined as a character array and a '\0'(NULL) character at the end
The think which you are doing is that you are displaying just characters not a string. As your program is reading NULL character first
+ 3
PRINCE KUMAR , this is a very obvious mistake that people make.🙂🙃
The problem is that you are displaying characters, not string as a whole
+ 3
Problem solved 👌 using two for loops it get solved
+ 1
Arsenic No because it is printing whole string in output
+ 1
I have never listened to 'a string' or 'several strings' or whatever and have always just scanf'ed what seemed to work best, single string, several strings, bunch of letters... output the same.
And that was never the problem.
Problem is rather that you arbitrarily start from 49 (where there would be a 0 anyway), although they might have given a shorter string.
+ 1
Yeah, you can use strlen from string.h.
Funny, didn't think of it. 😂
Basically, if you have an int i=0 flying around, all you have to do would be something like:
while(str[i++]);
0
I think my Python solution works also charakter for character. But only with the given input. Not 50 or some what else.
Hint: If you set i=6 or i=7 in your loop, then it will pass test case 1 or test case 2.
0
Start with 0 is not possible. He did it backwards. He need the lenght of the word as start. But then it must work.
Could it only test for i=6 and i=7.
0
any particular solution for it
0
HonFu I want to print reverse string. How can it start from 0
0
Make an int and run it up until you find the last letter '\0'.
Start one point lower, then read the string backwards.