In coach medium level pig latin | SoloLearn: Learn to code for FREE!

0

In coach medium level pig latin

#include <stdio.h> #include <string.h> int main() { char a[100]; int i,j,b=0,c; gets(a); c=strlen(a); for(i=0;i<c;i++) { if(a[i]!=' '){b++;} else if(a[i]=' '){ for(j=i-(b-1);j<i;j++){printf("%c",a[j]);} printf("%cay ",a[i-b]); b=0;} } return 0; }

3/11/2020 4:51:44 AM

Allepu Madhan mohan

5 Answers

New Answer

0

#include <stdio.h> #include <string.h> int main() { char a[100]; int i,j,b=0; gets(a); int c=strlen(a); a[c]=' '; for(i=0;i<=c;i++) { if(a[i]!=' '){b++;} else if(a[i]=' '){ for(j=i-(b-1);j<i;j++){printf("%c",a[j]);} printf("%cay ",a[i-b]); b=0;} } return 0; }

+2

hey Allepu Madhan mohan if you dont mind stating the problem you're facing with your code, that will make it easier to help you resolve your code, and you can include your code directly from playground using the plus icon on the bottom left

0

Allepu Madhan mohan your code is missing printing last word since you are printing when space encounters.. So to account last word also, add a space to input or change your logic... Hoping this will helps... You are asked similar question for same problem twice, after getting it solved, pls keep one and delete other, to eliminate dublicates

0

Thanks I got it now 👍 code is above

0

#include <stdio.h> #include <string.h> int main() { char a[100]; int i,j,b=0; gets(a); int c=strlen(a); a[c]=' '; for(i=0;i<=c;i++) { if(a[i]!=' '){b++;} else if(a[i]=' '){ for(j=i-(b-1);j<i;j++){printf("%c",a[j]);} printf("%cay ",a[i-b]); b=0;} } return 0; }