Created
May 14, 2015 20:13
-
-
Save jeanlucaslima/3b6f72810369fd27d4f9 to your computer and use it in GitHub Desktop.
ascii letters counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
char c = NULL; | |
int letters = 0, numbers = 0; | |
while(c != '\n') { | |
scanf("%c", &c); | |
if (c > 47 && c < 58) // if it's a number | |
numbers++; | |
if (c > 96 && c < 123) // if it's a capital letter | |
letters++; | |
if (c > 64 && c < 91) // if it's a letter | |
letters++; | |
} | |
printf("%d\n%d\n", letters, numbers); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment