-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhile.c
More file actions
26 lines (25 loc) · 696 Bytes
/
while.c
File metadata and controls
26 lines (25 loc) · 696 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
John Coder
July 3, 2024
*/
#include <stdio.h>
int main(void)
{
int blanks = 0, digits = 0, letters = 0, others = 0;
int c; // use for int value of character
while( (c = getchar() ) != EOF )
{
if (c == ' ' )
++blanks;
else if ( c >= '0' && c <= '9')
++digits;
else if ( c >= 'a' && c <= 'z' || c >= 'A' && c<= 'z')
++letters;
else
++others;
};
printf(" blanks = %d, digits = %d, letters = %d, ",
blanks, digits, letters);
printf(" others = %d\n\n", others);
return 0;
};