void gaz() {
auto average = ( foo() + bar() ) * 0.5;
}
The gaz is a function.
The gaz calculates the average of two numbers.
One number is received from function foo.
Other number is received from function bar.
My program is taking a text file and reading how many words, sentences, characters, simple sentences, average words per sentence, and how many sentences containing "to be". I made them into structures called Counts. I want to be able to group the results of the two functions below and divide them.
Function for words
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int countWords(Counts& counts, char line[])
{
counts.countWords=0;
char c;
int i=0;
while (line[i]!='\0')
{
c= line[i];
if (isspace(c))
{
counts.countWords++;
}
i++;
}
}
Function for Sentences
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int countSentences(Counts& counts, char line[])
{
counts.countSentences=0;
int i=0;
char p=0;
while (line[i] !='\0')
{
p=line[i];
if((p == '.')||(p == '?')||(p == '!'))
{
counts.countSentences++;
}
i++;
}
}