Skip to content

Commit

Permalink
New printy command
Browse files Browse the repository at this point in the history
  • Loading branch information
neale-pnnl committed Nov 15, 2023
1 parent 16ac8bd commit fb2cc4c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions printy.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdio.h>
#include <ctype.h>

int main(int argc, char *argv[]) {
int c;
unsigned int count = 0;
unsigned int printy = 0;

for (;;) {
c = getchar();
if (EOF == c) {
break;
}
if (isprint(c)) {
printy += 1;
}
count += 1;
}

printf("%f\n", printy/(float)count);

return 0;
}

0 comments on commit fb2cc4c

Please sign in to comment.