The program must accept a string S as the input. The program must print all the pairs having a consonant followed by a vowel in the string S (in the order of occurrence) as the output.
Note: The string S always contains at least one pair having a consonant followed by a vowel.
Boundary Condition(s):
2 <= Length of S <= 100
Input Format:
The first line contains the string S.
Output Format:
The first line contains all the pairs having a consonant followed by a vowel separated by a space.
Example Input/Output 1:
Input:
volcano
Output:
vo ca no
Explanation:
The string “volcano” contains three pairs having a consonant followed by a vowel. So the pairs vo ca and no are printed as the output.
Example Input/Output 2:
Input:
TELEVISION
Output:
TE LE VI SI
def is_vowel(c):
return c in 'aeiouAEIOU'
s = input().strip()
for i in range(len(s) - 1):
if not is_vowel(s[i]) and is_vowel(s[i+1]):
print(s[i] + s[i+1], end=" ")
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int isVowel(char c) {
c = tolower(c);
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
int main() {
char s[101];
scanf("%s", s);
int length = strlen(s);
for (int i = 0; i < length - 1; i++) {
if (!isVowel(s[i]) && isVowel(s[i+1])) {
printf("%c%c ", s[i], s[i+1]);
i++; // Skip the next character to avoid overlapping pairs
}
}
return 0;
}
#include <iostream>
#include <cctype>
using namespace std;
bool isVowel(char c) {
c = tolower(c);
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
int main() {
string s;
cin >> s;
for (int i = 0; i < s.length() - 1; i++) {
if (!isVowel(s[i]) && isVowel(s[i+1])) {
cout << s[i] << s[i+1] << " ";
i++;
}
}
return 0;
}
import java.util.Scanner;
public class ConsonantVowelPairs {
public static boolean isVowel(char c) {
c = Character.toLowerCase(c);
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String s = scanner.next();
for (int i = 0; i < s.length() - 1; i++) {
if (!isVowel(s.charAt(i)) && isVowel(s.charAt(i+1))) {
System.out.print(s.charAt(i) + "" + s.charAt(i+1) + " ");
i++;
}
}
}
}