Problem :- Write A C++ Program To Count Letters ,Space,Digits,And Others .
Logic :- If you Want to Understand This Problem You Need to See This Problem C++ Program To Find ASCII Value Of Any Character Or String .you also Can Modify .
Solution :-
Output:-
Logic :- If you Want to Understand This Problem You Need to See This Problem C++ Program To Find ASCII Value Of Any Character Or String .you also Can Modify .
Solution :-
#include<iostream>
#include<string>
using namespace std;
int main()
{
int i,ltr=0,digit=0,sp=0,oth=0;
char ch[50];
cout<<"Enter String :\n";
cin.getline(ch,50);
for(i=0;ch[i]!=0;i++)
{
if((97<=ch[i] && ch[i]<122) || (ch[i]<=90 && ch[i]>=65))
ltr++;
else if(ch[i]>=47 && ch[i]<=57)
digit++;
else if(ch[i]==32)
sp++;
else
oth++;
}
cout<<"letter :-"<<ltr<<"\ndigit :-"<<digit<<"\nspace :-"<<sp<<"\nother :-"<<oth;
return 0;
}
Output:-
0 Comments: