Tuesday, 5 December 2017

C program to convert Vowel into uppercase


Write a C-program which will take a word as an input whose maximum length will be 20 and it will convert the Vowels into uppercase and consonant into lowercase.  Example : "hello" will be changed as "hEllO".

#include<stdio.h>
int main()
{
    char a[20];
    int i=0;
    printf("Enter a lowercase Word: ");
    gets(a);
    while(a[i]!='\0')
    {
        if(a[i]>95 && a[i]<122)
        {
            if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'|| a[i]=='u')
                printf("%c",a[i]-32);
            else
                printf("%c",a[i]);

        }

        i++;
    }
    return 0;
}

OUTPUT:
 Enter a lowercase Word: hello ↲
                                                    hEllO                         


/* print a word with maximum length of 20 & convert the vowels into uppercase and consonants into lowercase. */

5 comments:

  1. can we write the above program if it is mention to write using command line program

    ReplyDelete
    Replies
    1. No, This is simple C Program. C using Command Line Argument will be a bit different than this code.

      Delete
  2. when i compile above programs in gcc compiler showing errors not only this program each and every program??how can i follow this program with these type of errors

    ReplyDelete
  3. when i compile above programs in gcc compiler showing errors not only this program each and every program??how can i follow this program with these type of errors

    ReplyDelete
    Replies
    1. I think there might be some problem in your compiler. I have personally compiled and run all the code of my blog in CodeBlocks. check again if there is any problem in your compiler.

      Delete

Featured Post

TCS Latest Test Patern ( For On-Campus Drives )

Tata Consultancy Services is software services consulting company whose  headquarter is situated in Mumbai, India. It is the Asia’s larges...