I wrote this program that works great except for when the avg isn't a whole number. If countWords is 3 and countSent is 2 then the program stops!!! Help!
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string str;
char ch;
int i;
int countSent, countWords;
float avg;
cout << "Enter sentences, when you are done press Enter: ";
i = 0;
cout << "The number of sentences entered is " << countSent << endl;
cout << "The number of words typed is " << countWords << endl;
cout << "The average number of words per sentence is " << avg << endl;
performs integer division of countWords by countSent then casts the result to a float.
You need to force floating point division. To do that, you must make sure that either
the divisor or the dividend is floating point to begin with (or both).
cout << "The number of sentences entered is " << countSent << endl;
cout << "The number of words typed is " << countWords << endl;
cout << "The average number of words per sentence is " << avg << endl;