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
Sample input:
Str[]=programming
Sample output:
Updated string=ogrammingpr
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main() {
char Str[]="programming";
char strNewString[20];
int i;
int c=0;
int index;
for (i = 0;i< strlen(Str); i++) {
if (tolower(Str[i]) == 'a' ||
tolower(Str[i]) == 'e' ||
tolower(Str[i]) == 'i' ||
tolower(Str[i]) == 'o' ||
tolower(Str[i]) == 'u') {
index=i;
break;
}
}
printf("Current string: %s\n",Str);
if(index!=-1){
for (i = index;i<strlen(Str); ++i) {
strNewString[c]=Str[i];
c++;
}
for (i =0;i<index; ++i) {
strNewString[c]=Str[i];
c++;
}
strNewString[c]='\0';
printf("New string: %s\n\n",strNewString);
}
getchar();
getchar();
return 0;
}
Comments
Leave a comment