Saturday, June 18, 2016

C Program Code: Alphabet to Number Converter Program

C Program Code

#include<stdio.h>
int main()
{
    char alphabet;
    int position;
    printf("Alphabet to Number Converter Program in C \n");
    printf("Enter Alphabet: ");
    scanf("%c", &alphabet);
    if (alphabet >= 65 && alphabet <= 90)
    {
        position = alphabet - 64;
        printf("Position of %c in English Alphabets is %d \n", alphabet, position);
    }
    else if (alphabet >= 97 && alphabet <= 122)
    {
        position = alphabet - 96;
        printf("Position of %c in English Alphabets is %d \n", alphabet, position);
    }
    else
        printf("you entered invalid Alphabet \n");
    printf("Press enter to continue... \n");
    fflush(stdin);
    getchar();
    return 0;
}


Alphabet to Number Converter in C Output Screenshot