-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy path43.c
33 lines (28 loc) · 818 Bytes
/
43.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
//Program to accept a string and count the number of digits, capital letters and small letters without using any library function
#include <stdio.h>
//#include <stdlib.h>
#define str_size 100
void main()
{
char str[str_size];
int cap=0, digit=0, small=0,i=0;
printf("\nInput the string : ");
scanf("%s",str);
while(str[i]!='\0')
{
if(str[i]>='a' && str[i]<='z')
small++;
else if(str[i]>='A' && str[i]<='Z')
cap++;
else if(str[i]>='0' && str[i]<='9')
digit++;
else{
i++;
continue;
}
i++;
}
printf("Number of digits in the string is : %d\n", digit);
printf("Number of capital letters in the string is : %d\n", cap);
printf("Number of small letters in the string is : %d\n", small);
}