C Coding Questions With Solutions


Question :

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".

  
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;
}