\* hello im new in this thing of programming and especially in C.
this program was done by me to calculate the sum of numbers i meant letters.
ex: if i write ab in console get calculation like that:
if a=1 and b=2 then sum = 1+2=3. when i type a word in console, space bar another word, enter i get an error with possibilities [abort], [retry], [ignore].
#include <stdio.h >
int main ()
{
char string1[20];
int sum1; int sum2; int sum3; int sum4;
int sum5; int sum6; int sum7; int sum8;
int sum9; int sum10; int sum11; int sum12;
int sum13; int sum14; int sum15; int sum16;
int sum17; int sum18; int sum19; int sum20;
int sum21; int sum22; int sum23; int sum24;
int sum25; int sum26; int sum27; int sum28;
int sum29; int sum30; int sum31; int sum32;
int sum33;
int i;
int sum;
printf (" my word is:");
scanf ( "%s\n ", string1);
if (string1[i]==a ) {sum= sum +sum1;}
if (string1[i]==b ) {sum= sum +sum2;}
if (string1[i]==g ) {sum= sum +sum3;}
if (string1[i]==d ) {sum= sum +sum4;}
if (string1[i]==e ) {sum= sum +sum5;}
if (string1[i]==v ) {sum= sum +sum6;}
if (string1[i]==z ) {sum= sum +sum7;}
if (string1[i]==T ) {sum= sum +sum8;}
if (string1[i]==I ) {sum= sum +sum9;}
if (string1[i]==k ) {sum= sum +sum10;}
if (string1[i]==l ) {sum= sum +sum11;}
if (string1[i]==m ) {sum= sum +sum12;}
if (string1[i]==n ) {sum= sum +sum13;}
if (string1[i]==o ) {sum= sum +sum14;}
if (string1[i]==p ) {sum= sum +sum15;}
if (string1[i]==j ) {sum= sum +sum16;}
if (string1[i]==r ) {sum= sum +sum17;}
if (string1[i]==s ) {sum= sum +sum18;}
if (string1[i]==t ) {sum= sum +sum19;}
if (string1[i]==u ) {sum= sum +sum20;}
if (string1[i]==f ) {sum= sum +sum21;}
if (string1[i]==q ) {sum= sum +sum22;}
if (string1[i]==R ) {sum= sum +sum23;}
if (string1[i]==w ) {sum= sum +sum24;}
if (string1[i]==C ) {sum= sum +sum25;}
if (string1[i]==W ) {sum= sum +sum26;}
if (string1[i]==x ) {sum= sum +sum27;}
if (string1[i]==zz ) {sum= sum +sum28;}
if (string1[i]==h ) {sum= sum +sum29;}
if (string1[i]==c ) {sum= sum +sum30;}
if (string1[i]==Z ) {sum= sum +sum31;}
if (string1[i]==J ) {sum= sum +sum32;}
if (string1[i]==y ) {sum= sum +sum33;}
if (string1[i]=='\0' ) {sum= sum +0;}
printf ("%d\n" , sum);
return 0;
You can use the int representations of char to add to sum. In the code below, we must subtract by 96 because the ASCII int value of 'a' is 97. When we hit NULL, we simply stop. Just in case the user entered a character that is not a letter, we print an error.