Thursday, 17 January 2019

Toggle Case - Vowels

The program must accept a string S as the input. The program must toggle the case of vowels in the string S. Then the program must print the modified string as the output.

Boundary Condition(s):
1 <= Length of S <= 100

Input Format:
The first line contains the string S.

Output Format:
The first line contains the modified string.

Example Input/Output 1:
Input:
EquilIbriUm

Output:
eqUIlibrIum

Explanation:
The vowels in the string "EquilIbriUm" are 'E', 'u', 'i', 'I', 'i' and 'U'.
So toggle the case of all the vowels in the string "EquilIbriUm".
Hence the output is eqUIlibrIum

Example Input/Output 2:
Input:
JUNKVIRUS

Output:
JuNKViRuS

Program
#include<stdio.h>
#include <stdlib.h>

int main()
{
  char S[100];
  int i=0;
  scanf("%s",S);
  
  while(S[i]!='\0')
  {
    switch (S[i])
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u': S[i]=toupper(S[i]);
                  break;
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U': S[i]=tolower(S[i]);
                  break; 
    } 
    ++i;
  }
  printf("%s",S);
     
      
}

OUTPUT
EvaluAte
evAlUatE