forked from Vishal-Aggarwal0305/DSA-CODE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TotalChar.c
46 lines (41 loc) · 1.11 KB
/
TotalChar.c
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
35
36
37
38
39
40
41
42
43
44
45
46
#include <stdio.h>
#include <string.h>
int main()
{
int noc=0,sp=0,tab=0,lines=0,sym=0,cap=0,small=0,dig=0;
char str[100];
printf("Enter the lines\nPress $ to terminate string\n");
// scanf("%[^$]", str);
scanf("%s", str);
for(int i=0;i<strlen(str);i++)
{
noc++;
if(str[i]== '\\' && str[i+1]=='n')
{
lines++;
sp++;
}
else if(str[i]==' ')
sp++;
else if(str[i]=='\t')
{
tab++;
sp++;
}
else if(str[i]>=65 && str[i]<=90)
cap++;
else if(str[i]>=97 && str[i]<=122)
small++;
else if(str[i]>=48 && str[i]<=57)
dig++;
else
sym++;
}
printf("Total No of characters are %d\n",noc);
printf("Total No of small alphabets are %d\n",small);
printf("Total No of capital alphabets are %d\n",cap);
printf("Total No of digits are %d\n",dig);
printf("Total No of tabs are %d\n",tab);
printf("Total No of words are %d\n",sp+1);
printf("Total No of lines are %d\n",lines+1);
}