1 Attachment(s)

Counting letters and digits

I have problem - i can't find way to count letters and digits from arrary. I need to make it for school at the begin you enter some kind of symbols random. Example: adsadDEARFasda3213Eras Then you enter symbol for example: a, first - programm counst how many time you have entered a -> gives to you result, then programm counts how many letters are in your arrary and print out and the same with digits, but i can't find fuction whom can count digits and letters independent i have found only function strlen(arraryName) which counts all elements in arrary...

In fact problem is I need function which counts 1. small and big letters 2. counts how many digits are in my arrary

In fact i need two separate functions... :rolleyes:

Code of my programm:

Code:

`#include <iostream>`

#include <iomanip>

using namespace std;

void svitra();

int main()

{

char simbv[50];

char simb;

int daudz=0;

cout<<"Ievadiet simbolu virkni, lai taja butu:"<<endl;

cout<<setw(33)<<"simbols,kas atkartojas;\n"<<setw(17)<<"cipari;\n"<<setw(22)<<"lielie burti."<<endl;

svitra();

cout<<"\n==>"; cin.get( simbv, 50, '\n'); // Enter some random letters small and big and digits

svitra();

cout<<"\nIevadiet simbolu, lai: \n"<<setw(45)<<"noteiktu, cik reizes tas atkartojas\n"<<setw(28)<<"to aizvietotu ar *."<<endl;

svitra();

cout<<"\n==>"; cin>>simb; // enter symbol which will be showed how many time

svitra();

for ( int i=0; i<=50; i++ )

if ( simbv[i] == simb )

daudz++;

cout<<"\nk ==> "<<daudz<<" reizes!"; // how many times you have entered symbol

cout<<endl;

system("pause");

return 0;

}

void svitra()

{

for ( int i=0; i<60; i++)

cout<<"-";

}