Skip to content

Instantly share code, notes, and snippets.

@jeanlucaslima
Created May 14, 2015 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeanlucaslima/3b6f72810369fd27d4f9 to your computer and use it in GitHub Desktop.
Save jeanlucaslima/3b6f72810369fd27d4f9 to your computer and use it in GitHub Desktop.
ascii letters counter
#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