Add solution for alphabet.
This commit is contained in:
parent
f2502d0dae
commit
c0f9b4241a
@ -19,3 +19,31 @@
|
||||
* Die folgende Ausgabe ist richtig, weil das Zeichen 3 ein Buchstabe ist: 0 *
|
||||
* Der Buchstabe 3 ist der -13. Buchstabe im Alphabet. *
|
||||
*****************************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned char character = 'a';
|
||||
|
||||
printf("Eingabe: ");
|
||||
|
||||
while(character != '\n')
|
||||
{
|
||||
unsigned char lowerChar;
|
||||
|
||||
character = getchar();
|
||||
|
||||
lowerChar = tolower(character);
|
||||
|
||||
if(lowerChar >= 'a' && lowerChar <= 'z')
|
||||
{
|
||||
unsigned int alphaPos = lowerChar - 'a' + 1;
|
||||
printf("Der Buchstabe %c liegt an %u. Stelle im Alphabet.\n", character, alphaPos);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user