Respuesta :

Answer:

#include <iostream>

int countLetters(char s[])//function to return letter count..

{

   int c=0;//initialising a variable c with 0 .

   for(int i=0;s[i];i++)//iterating over the string..

   {

       if(s[i]==' ')//not counting spaces in the string...

       continue;//skips the current iteration jumps over to next iteration..

       c++;//increasing the count...

   }

   return c;//returning the count...

}

using namespace std;

int main() {

char string[500];//taking a string of max 499 characters...

cout<<"enter text "<<endl;

cin.getline(string,499);//taking input of the string max 499 characters 500th character hould be null character...

int count=countLetters(string);//calling the function..

cout<<count<<endl;//printing the count...

return 0;

}

Explanation:

I have taken an integer c in the function to store the count.

Iterating over the string if space is encountered then not increasing the count else increasing the count.

Returning the count at last.

RELAXING NOICE
Relax