-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexp11_12_2.c
More file actions
34 lines (34 loc) · 876 Bytes
/
exp11_12_2.c
File metadata and controls
34 lines (34 loc) · 876 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
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <ctype.h>
#include <stdbool.h>
int main()
{
char c;
bool inword = false;
int in_words, uppercase, lowercase, interpunction, digit;
in_words = uppercase = lowercase = interpunction = digit = 0;
printf("please enter character:\n");
while ((c = getchar()) != EOF)
{
if (isupper(c))
uppercase++;
if (islower(c))
lowercase++;
if (ispunct(c))
interpunction++;
if (isdigit(c))
digit++;
if (!isspace(c) && !inword)
{
inword = true;
in_words++;
}
if (isspace(c) && inword)
{
inword = false;
}
}
printf("in_words:%d ,uppercase:%d ,lowercase:%d ,interpunction:%d ,digit:%d\n",
in_words, uppercase, lowercase, interpunction, digit);
return 0;
}