A program that read any line of text & display number of upper case, lower case, digit, space& other character

#include<iostream>
using namespace std;
int main()
{
int up=0,lo=0,di=0,space=0,other=0,i=0;
char text[100];
cout<<"Enter text :";
cin.getline(text,100);
while(text[i]!=0)
{
int c=int(text[i]);
if (c>=65 && c<=90)
up++;
else if(c>=97 &&c<=122)
lo++;
else if(c>=48 &&c<=57)
di++;
else if(text[i]==' ')
space++;
else
other++;
++i;
}
cout<<"\n\nResult:\n";
cout<<"Uppercase"<<up<<endl;
cout<<"Lowercase"<<lo<<endl;
cout<<"Digit"<<di<<endl;
cout<<"Spaces"<<space<<endl;
cout<<"Other"<<other<<endl;
cout<<"\n\n";
cout<<"/*\nName-Sanjampreet Singh\nRoll Number-1507967\n*/";
}

Output:


Comments

Popular posts from this blog

To implement the various components of HTML5 Canvas

Program to illustrate the concept of templates.

Program to illustrate the order of execution of constructors and destructors in inheritance.