given a string "programming" and find the first occurrence of the vowel and move the sequence of consonants preceding the first vowel to the end of the string. write a c program.
Sample input:
Str[]=programming
Sample output:
Updated string=ogrammingpr
#include <stdio.h>
#include <string.h>
int main() {
char str[] = "programming";
int n = strlen(str);
int i, j;
char ch;
for (i=0; i<n; i++) {
if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' ||
str[i] == 'o' || str[i] == 'u' || str[i] == 'y' ) {
break;
}
}
if (i==n) {
return 0;
}
while (i>0) {
ch = str[0];
for (j=1; j<n; j++) {
str[j-1] = str[j];
}
str[n-1] = ch;
i--;
}
printf("%s\n", str);
return 0;
}
Comments
Leave a comment