Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ahmadali-jamali/a55ff5d2cacbb9287180c72a6c4890d0 to your computer and use it in GitHub Desktop.
Save ahmadali-jamali/a55ff5d2cacbb9287180c72a6c4890d0 to your computer and use it in GitHub Desktop.
The program which count capital and small alphabets, vocab by C++
/* Name of the Programm : Print of count of capital and small, digit data type.
Ahmadali Jamali
11/13/2019*/
//>>>START
// Libraries
#include <iostream>
#include <string>
using namespace std;
//Functions:
//1 Input Function:
string Input(){
string text;
cout<<"Please enter your text and then press enter key: \n";
getline (cin,text);
return text;
}
//2 Processing Function:
int Counter(string TEXT){
int Lenght = TEXT.size();
int count1 = 0;
int count2 = 0;
int count3 = 0;
int count4 = 0;
for (int i = 0; i<Lenght; i++){
if ((int)TEXT[i]>=97 && (int)TEXT[i]<=122){
count1++;
}
else if ((int)TEXT[i]>=65 && (int)TEXT[i]<=90){
count2++;
}
else if ((int)TEXT[i]>=48 && (int)TEXT[i]<= 57){
count3++;
}
else if ((int)TEXT[i]==32){
count4++;
}
}
cout <<"This is Number of small alphabet: \n"<<count1<<"\n";
cout <<"This is Number of capital alphabet: \n"<<count2<<"\n";
cout <<"This is Number of digit: \n"<<count3<<"\n";
cout <<"This is Number of space: \n"<<count4<<"\n";
return count1,count2,count3,count4;
}
//Main Function:
int main() {
string Textw;
Textw = Input();
Counter(Textw);
string end;
cin>> end;
return 0;
}
// End of the Programm.........
// Ahmadali Jamali
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment