GeeksforGeeks Solution For School Domain .Below You Can Find The Solution Of Basic ,Easy ,Medium ,Hard .You Can Also Direct Submit Your Solution to Geeksforgeeks Same Problem .You Need to login then you can submit you answers
Problem :- Given a string, print the number of alphabets present in the string.
Submit Your Solution :- Click Here
Solution :-
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int i,temp=0,tmp=0;
string str;
cin>>str;
for(i=0;i<str.length();i++)
{
if(str[i]>=97&&str[i]<=122||str[i]>=65&&str[i]<=90)
temp++;
else
tmp++;
}
cout<<temp<<endl;
}
return 0;
}
Output:-
0 Comments: