Hey anyone that can help would be greatly appreciated
I am writing a code to output the number placement of a letter in the alphabet. I already understand how to find the number placement by minus 64 for lowercase and 96 for upper. What I need help with is figuring out how to add the suffix for it (st, nd, rd,th), such as 1st, 2nd, ect.
What code do you have already? When you do post code, make sure you use code tags with the <> button on the format menu
Have you considered using a switchstatement? If so look it up in the reference section at the top left of this page. There is also the tutorial & articles.
hey thanks for the reply, I have a lot of code because my homework consists of a lot other than this but ill post the section im on now and if you need more ill post it.
1 2 3 4 5 6 7 8 9 10 11
//output character place in alphabet if a letter
if (FavChar >= 65 && FavChar <= 90)
{
NumPlace = FavChar - 64;
}
elseif (FavChar >= 97 && FavChar <= 122)
{
NumPlace = FavChar - 96;
}
cout << "\n\tand it is number " << NumPlace << "in the alphabet";
Your very right about the switch statement, if I mod by 10 then I can get the last digit and apply the correct suffix, the only problem is how to deal with 1st vs 11th, 2nd vs 12th,and 3rd vs 13th