Code:
//Write a program that reads characters from the standard input to end-of-file. For//each character, have the program report whether it is a letter. If it is a letter, also
//report its numerical location in the alphabet. For example, c and C would both be
//letter 3. Incorporate a function that takes a character as an argument and returns
//the numerical location if the character is a letter and that returns –1 otherwise.
#include <stdio.h>
int main (void){
char ch;
int i;
const char s_letters[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
const char c_letters[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
printf ("Enter one letter: ");
while ((ch=getchar())!=EOF && ch!='`'){
for(i=0;i<26;i++){
if (s_letters[i]==ch)
printf("Position of %c in English Alphabets is %d\n\n",ch,i+1);
else if (c_letters[i]==ch)
printf("Position of %c in English Alphabets is %d\n\n",ch,i+1);
}
printf ("Enter one letter again or ` for quit: ");
ch=getchar();
}
printf ("Exit...");
return 0;
}