A=1,B=2,C=3,.......... C A T=3+1+20=24
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<conio.h>
void main()
{
char a[100];int i,l=0,b[100],s=0;
printf("\nEnter word: ");
gets(a);
l=strlen(a);
for(i=0;i<l;i++)
{
if(isupper(a[i]))
b[i]=a[i]-64; /*ASCII value of capital A is 65.So for A to be 1 subtract 64*/
if(islower(a[i]))
b[i]=a[i]-96; /*ASCII value of small a is 97.So for a to be 1 subtract 96*/
printf("\n%c : %d",toupper(a[i]),b[i]);
}
printf("\n _____");
for(i=0;i<l;i++)
s=s+b[i];
printf("\n %d",s);
printf("\n _____");
getch();
}
Download source and exe here
No comments:
Post a Comment