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; }

11th Mar 2020, 4:51 AM
Allepu Madhan mohan
Allepu Madhan mohan - avatar
5 Answers
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; }
11th Mar 2020, 4:49 PM
Allepu Madhan mohan
Allepu Madhan mohan - avatar
+ 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
11th Mar 2020, 4:58 AM
āœ³AsterisKāœ³
āœ³AsterisKāœ³ - avatar
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
11th Mar 2020, 4:33 PM
Jayakrishna šŸ‡®šŸ‡³
0
Thanks I got it now šŸ‘ code is above
11th Mar 2020, 4:50 PM
Allepu Madhan mohan
Allepu Madhan mohan - avatar
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; }
11th Mar 2020, 4:59 PM
Allepu Madhan mohan
Allepu Madhan mohan - avatar