I've written a program to count no. of uppercase, lowercase, spaces and special characters. I want to make separate functions to count each type. How can I do that?
#include<iostream>
using namespace std;
int main()
{
int upper = 0, lower = 0, space = 0, special = 0;
char sentence[100];
char space1 = ' ';
int i;
cout<< "Enter The String : ";
cin.getline(sentence, 80);
i = 0;
while (sentence[i] != '\0') {
if (sentence[i] >= 'A' && sentence[i] <= 'Z')
upper++;
if (sentence[i] >= 'a' && sentence[i] <= 'z')
lower++;
if (sentence[i] == space1)
space++;
if((sentence[i]>=33&&sentence[i]<=47)||(sentence[i]>=58&&sentence[i]<=64)||(sentence[i]>=91&&sentence[i]<=96))
special++;
i++;
}
cout<< "No. of Capital letters: "<<upper<<endl;
cout<< "No. of Small letters: "<<lower<<endl;
cout<< "No. of Spaces: "<<space<<endl;
cout<< "No. of Special characters: "<<special<<endl;
return (0);
}