Count Total number of Capital and Small Letters from Accepted Line
#include<stdio.h> #include<conio.h> void main() { int upper=0,lower=0; char ch[80]; int i; clrscr(); printf("\nEnter The String : "); gets(ch); i=0; while(ch[i]!='\0') { if(ch[i]>='A' && ch[i]<='Z') upper++; if(ch[i]>='a' && ch[i]<='z') lower++; i++; } printf("\nUppercase Letters : %d",upper); printf("\nLowercase Letters : %d",lower); getch(); }
Output :
Enter The String : Pritesh A Taral Uppercase Letters : 3 Lowercase Letters : 10
Program Categorized Under : String Programs in C
Explanation :
if(ch[i]>='A' && ch[i]< ='Z')
- We can compare two Characters.
- Generally Comparing Characters means Comparing Corresponding ASCII Values.
if('Z' > 'A')
meanse
if('Z' > 'A') = if(ASCII Value 'Z' > ASCII Value 'A') = if(90 > 65)
Incoming search terms:
- if lower case letter program c (2)
- java code tocounts the number of the small letters and the number of capital letters (1)
- java number list c language count (1)
- java program that counts lower case and upper case letters from multiple strings (1)
- java program to convert lowercase alphabet to uppercase (1)
- java program to find the count of small and big letters (1)