- 1

Hi I need to know How to write a C program which shows Alphabet Letter position when you type alphabet letter

17th Aug 2018, 10:33 AM
Srikanth
Srikanth - avatar
5 Antworten
+ 2
What do you mean by "position" here? did you mean its ord number? e.g. 'A' -> 65 ?
17th Aug 2018, 11:02 AM
Ipang
+ 2
char c; scanf("%c", &c); printf("%d\n", (c - 'A') +1);
17th Aug 2018, 11:13 AM
Vlad Serbu
Vlad Serbu - avatar
+ 2
well, you could use a map and have the corresponding position be the value of your string or character key, or with a bit more work you could create a parallel array structure with a search function that return the index of the entered letter in the first array and feed it to the second array, or you could just create a single array of characters and the alphabet position be equal to your index plus 1.
17th Aug 2018, 11:24 AM
StealthyTaco
StealthyTaco - avatar
0
No it's not ord number for example the letter "A" alphabet position is 1 like that I am asking for a A -Z. In output if I type the Letter "C" it must show the position number of the alphabet is 3
17th Aug 2018, 11:07 AM
Srikanth
Srikanth - avatar
0
char c; scanf("%c",&c); printf("%d\n",( (c-'A')-31);
1st Jun 2021, 9:44 AM
ARJUN PK
ARJUN PK - avatar