Friday, September 2, 2016

Tags

PROGRAM TO FIND NO OF CHARACTERS,DIGITS,SPACES,SPECIAL CHARACTERS IN A STRING :)
#include<iostream>
#include<cstring>
using namespace std;
main()
{  static int i,c,a,d,sp,sc;
string s;

cout<<"ENTER THE string";
getline(cin,s);
cout<<s;
while(s[i]!='\0')
{
if(s[i]>='A'&&s[i]<='z')
{
c++;}
else if(s[i]>='1'&& s[i]<='9')
{
d++;}
else if(s[i]==' ')
sp++;
else
{
sc++;}
i++;
}
cout<<"\nCHARACTERS "<<c;
cout<<"\nSPECIAL CHARACTERS "<<sc;
cout<<"\nDIGITS"<<d;
cout<<"\n SPACES"<<sp;
}