Answer to Question #218010 in C for Hemambar

Question #218010

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


1
Expert's answer
2021-07-16T10:50:05-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS