Input a character and this algorithm will tell you which type of character it is.

In Python language:-

def whichar(c):

    if(c>='A'and c<='Z'):

        if(c=='A'or c=='E'or c=='I'or c=='O'or c=='U'):
            print("Is a capital letter and a vowel")
        else:
            print("Is a capital letter and a consonant")

    elif(c>='a'and c<='z'):

        if(c=='a'or c=='e'or c=='i'or c=='o'or c=='u'):
            print("Is a small case letter and a vowel")
        else:
            print("Is a small case letter and a consonant")

    elif(c>='0'and c<='9'):
        print("Is a digit")
    elif(c==' '):
        print("Is a space")
    else:
        print("Is a special character")

In C language:-

#include<stdio.h>
void main()
{
    char c;

    printf("Enter a character:- ");
    scanf("%c", &c);

    if(c>='A'&&c<='Z')

        if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U')
            printf("Is a capital letter and a vowel\n");
        else
            printf("Is a capital letter and a consonant\n");

    else if(c>='a'&&c<='z')

        if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
            printf("Is a small case letter and a vowel\n");
        else
            printf("Is a small case letter and a consonant\n");

    else if(c>='0'&&c<='9')
        printf("Is a digit\n");
    else if(c==' ')
        printf("Is a space\n");
    else
        printf("Is a special character\n");
}
Advertisements

#c, #python