- 1
Hi I need to know How to write a C program which shows Alphabet Letter position when you type alphabet letter
5 odpowiedzi
+ 2
What do you mean by "position" here? did you mean its ord number? e.g. 'A' -> 65 ?
+ 2
char c;
scanf("%c", &c);
printf("%d\n", (c - 'A') +1);
+ 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.
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
0
char c;
scanf("%c",&c);
printf("%d\n",( (c-'A')-31);