Friday 3 November 2017

CO4 Assignment 6th Question solution

Sunny is fond of Vowels. In a given line of text he wanted to see all lower-case vowels in uppercase & vice-versa. Write a C program to implement Sunny’s wish.
Ex:
Input: India is my country.
Output: IndIA Is my cOUntry.

Solution:



#include <stdio.h>
main()
{
               char str[100];
               int i;
               printf("enter a string");
               gets(str);
               for(i=0;str[i]!='\0';i++)
               {
                              if(str[i] == 'A'|| str[i] == 'E'||str[i] == 'I'||str[i] == 'O'||str[i] == 'U')
                                             str[i]=str[i]+32;
                              if(str[i] == 'a'|| str[i] == 'e'||str[i] == 'i'||str[i] == 'o'||str[i] == 'u')
                                             str[i]=str[i]-32;
               }
               puts(str);
}

No comments:

Post a Comment