T
The Conqueror
Guest
The problem is to print the total number of upper case characters, lower case characters and blank spaces in a string.
Here is my code :
Well , I do get the correct number of lower case and upper case characters. But it shows number of blank characters as 0.
Here is my code :
Code:
#include <stdio.h>
#include <string.h>
int main()
{
int blank = 0;
int upper=0; int lower = 0;
char ch[80];
int i;
gets(ch);
i=0;
while(ch[i] != ' ')
{
if(ch[i]>= 'A' && ch[i] <= 'Z')
upper++;
if(ch[i]>= 'a' && ch[i] <= 'z')
lower++;
i++;
}
i=0;
while(ch[i] == ' ')
{
blank ++;
i++;
}
printf(" Uppper Case : %d, Lower Case : %d, Blank Spaces : %d", upper, lower, blank);
return 0;
}
Well , I do get the correct number of lower case and upper case characters. But it shows number of blank characters as 0.