What is the error

only one case is satisfied

#include <stdio.h> #include<string.h> int main() { int i,j=1; char str[10]; scanf("%s",str); for(i=0;i<strlen(str);i++) { if(str[i]==str[i+1]) { j++;} printf("%c",str[i]); if(str[i]!=str[i+1]) { printf("%d",j); j=1; }} return 0;}

hello @sukiratwarring,
please save ur code on -> https://ide.codingblocks.com/
and share the link

@sukiratwarring
image

actual output should be -> a2b1c1

image
add this line inside if statement( line no 11)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.