77 964
Assignments Done
Successfully Done
In August 2019

Answer to Question #27959 in C++ for bashar

Question #27959
write a program that will input a sentence ending with a dot, then find the number of letters and the number of words in this sentence.
Expert's answer
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <math.h>
#include <memory.h>
#include <ctype.h>

using namespace std;

int main() {
char q;
char prev = ',';
int cnt_letters, cnt_words;
cnt_letters = cnt_words = 0;
for (;;) {
& scanf("%c", &q);
& if (q == '.') break;
& if (isalpha(q)) {
if (!isalpha(prev))
& }
& prev = q;
printf("Number of letters: %d\n", cnt_letters);
printf("Number of words: %d\n", cnt_words);
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions