0

About extra-terrestrials problem

I'm stuck with this problem . 2/5 tests failed. Please help me what is wrong with this code #include <stdio.h> #include <string.h> int main() { int i,n; char b[100],a[100]; scanf("%[^\n]%*c",b); n=strlen(b); for (i=0;i<n;i++) { a[n-1-i]=b[i];} printf("%s",a); return 0; }

10th Apr 2020, 8:27 PM
Monika
2 Antworten
+ 1
Seems fine. May be adding extra space. Since input only a word, %s is enough in scanf. So Try with scanf("%s", b);
10th Apr 2020, 9:10 PM
Jayakrishna 🇮🇳
0
Thanks that fixed the problem
10th Apr 2020, 9:18 PM
Monika