15. Find the number of special characters in a given string.
#include
<stdio.h>
int main()
{
char
str[100];
int
i, special;
clrscr();
i = special = 0;
printf("\n Please Enter any
String :
");
gets(str);
while
(str[i] != '\0')
{
if(!((str[i] >= 'a'
&& str[i] <= 'z') || (str[i] >= 'A' && str[i] <=
'Z')|| (str[i] >= '0' && str[i] <= '9')))
special++;
i++;
}
printf("\n Number of Special
Characters in this String = %d", special);
getch();
return
0;
}
No comments:
Post a Comment