i need some help here....i am taking input as name and i want to count the alphabets in the string as integers....e.g. if the in out is cab i have to output 3+1+2 = 5 i have been able to ad d up the strings..but if my input starts with a " " (space) it does not wrk...please help
n = toLowerCase(n);
for(int i = 0 ; i<n.length() ; i++)
{
lower = lower + n.at(i);
}
for(int k=0;k<n.length();k++)
{
index=index+int(n.at(k)-96);
cout<<index<<endl;
//just to see adding
}
while(index>=10)
{
temp=temp+index%10;
index=index/10;
s2=sum=temp+index;
}
sum=sum%10;
s2=s2/10;
a=sum+s2;
cout<<a<<endl;
if(a==1)
cout<<"1you are quirky and eccentric"<<endl;
else if(a==2)
cout<<"2you are introvert and shy"<<endl;
else if(a==3)
cout<<"3you are party animal"<<endl;
else if(a==4)
cout<<"4you are trustworthy and reliable"<<endl;
else if(a==5)
cout<<"5you are patient and forgiving"<<endl;
else if(a==6)
cout<<"6you are friendly and jovial"<<endl;
else if(a==7)
cout<<"7you are lucky and talented"<<endl;
else if(a==8)
cout<<"8you are genius"<<endl;
else if(a==9)
cout<<"9you are street-smart and cunning"<<endl;