Write a function that counts the number of letters in the string using the following header:
int countLetters(const char s[])
Write a test program that reads a C-string and displays the number of letters in the string. Here is a sample run of the program:
```
```
#include
#include
using namespace std;
int countLetters(const char s[])
{
int count = 0;
for (int i = 0; i < strlen(s); i++)
{
if (isalpha(s[i])) count++;
}
return count;
}
int main()
{
// Prompt the user to enter a string
cout << "Enter a string: ";
char s[80];
cin.getline(s, 80);
cout << "The number of letters in " << s << " is " <<
countLetters(s) << endl;
return 0;
}
```
You might also like to view...
The basic input/output system (BIOS) is stored on a ________ chip
A) RAM B) CMOS C) ROM D) CPU
When a slide is appropriate in a presentation but not suitable for the current audience the slide should be hidden
Indicate whether the statement is true or false
The Edit command allows you to change multiple occurrences of the same text in a presentation
Indicate whether the statement is true or false
Which of the following is NOT a medium used for storing digital images?
a. Internal memory b. SD card c. CompactFlash card d. None of the above