Upper Case Letter Count C++
upper case letter count C++
#include<iostream>
using namespace std;
//Count Uppercase, Lowercase, special character and numeric value
void count(string str){
int Uppercase = 0;
int Lowercase = 0;
int digit = 0;
int special_character = 0;
for (int i = 0; i < str.length(); i++){
if (str[i] >= 'A' && str[i] <= 'Z'){
Uppercase++;
}
else if(str[i] >= 'a' && str[i] <= 'z'){
Lowercase++;
}
else if(str[i]>= '0' && str[i]<= '9'){
digit++;
}
else{
special_character++;
}
}
cout<<Uppercase<< endl;
}
int main(){
string str;
cin>>str;
count(str);
return 0;
}
Comments
Post a Comment