Friday, May 3, 2019

Case Count

Problem Description 

C PROGRAM TO COUNT NUMBER OF UPPERCASE AND LOWERCASE LETTERS FROM A SENTENCE 

Test Case 1
 Input (stdin) 
Arun IS a GooD

Expected Output
 Uppercase Letters=5
 Lowercase Letters=6 

Test Case 2 
Input (stdin)
 HELLO SRMM CHENN

Expected Output
 Uppercase Letters=14
 Lowercase Letters=0

Solution


#include <stdio.h>
int main()
{
char str[100];
int countL,countU;
int counter;
countL=countU=0;
scanf ("%[^\n]s",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("Uppercase Letters=%d\nLowerCase Letters=%d",countU,countL);
return 0;
}

No comments:

Post a Comment

Parity

Problem Description Ram and Sita playing the parity game. Two types of parity are there. One is odd parity and next is even parity. Ram will...