Obtain a string from the terminal and count the numbers of uppercase letters, lowercase letters, numbers, and other characters ., Uppercase letters and lowercase letters
// Obtain a string from the terminal and count the numbers of uppercase letters, lowercase letters, numbers, and other characters.
# Include <stdio. h>
# Include <stdio. h>
Int main (int argc, const char * argv [])
{
Char str [100];
Char ch;
Int len, I;
Int letter = 0, number = 0, space = 0, other = 0;
Gets (str );
For (I = 0; I <strlen (str); I ++)
{
Ch = str [I];
If (ch> = 'A' & ch <= 'Z') | (ch> = 'A' & ch <= 'Z '))
{
Letter ++;
}
Else if (ch> = '0' & ch <= '9 ')
{
Number ++;
}
Else if (ch = '')
{
Space ++;
}
Else
{
Other ++;
}
}
Printf ("letter = % d \ nnumber = % d \ nspace = % d \ nother = % d \ n", letter, number, space, other );
Return 0;
}
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.