write a program in c to count the number of upper case and lower case alphabet in a string
Answers
Answer:
hello kitty is it ok for you to do this but I have a pleasant
Answer:
This c program will read a string and count total number of uppercase and lowercase characters in it. To test, which is lowercase or uppercase character, we need to check that character is between ‘A’ to ‘Z’ (Uppercase character) or ‘a’ to ‘z’ (Lowercase character).
Example:
Input string: This is a Test String.
Output:
Total Upper case characters: 3,
Lower Case characters: 14
Explanation:
/*C program to count upper case and lower case characters in a string.*/
#include <stdio.h>
int main()
{
char str[100];
int countL,countU;
int counter;
//assign all counters to zero
countL=countU=0;
printf("Enter a string: ");
gets(str);
for(counter=0;str[counter]!=NULL;counter++){
if(str[counter]>='A' && str[counter]<='Z')
countU++;
else if(str[counter]>='a' && str[counter]<='z')
countL++;
}
printf("Total Upper case characters: %d, Lower Case characters: %d",countU,countL);
return 0;
}