Open In App

Encoding a word into Pig Latin

Improve
Improve
Like Article
Like
Save
Share
Report

Design a program to take a word as an input, and then encode it into Pig Latin. A Pig Latin is an encrypted word in English, which is generated by doing the following alterations:
The first vowel occurring in the input word is placed at the start of the new word along with the remaining alphabet of it. The alphabet is present before the first vowel is shifted, at the end of the new word it is followed by “ay”. 

Examples:  

Input: s = "paris"
Output: arispay

Input: s = "amazon"
Output: amazonay 
  1. Find index of first vowel.
  2. Create pig latin by appending following three.
    1. Substring after starting with the first vowel ……..till end.
    2. Substring before first vowel.
    3. “ay”.

Implementation:

CPP





Java





Python3





C#





Javascript





Output

aphicgray

 



Last Updated : 22 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads