How to count sentences in a paragraph..." using c language
Solved/Closed
gealon2024
Posts
7
Registration date
Thursday October 3, 2013
Status
Member
Last seen
April 30, 2014
-
Oct 3, 2013 at 10:11 PM
indhu - Jan 10, 2016 at 08:47 AM
indhu - Jan 10, 2016 at 08:47 AM
Related:
- Paragraph on c
- Count if cell contains number - Excel Forum
- How to count names in excel - Guide
- Do chats count towards best friends on snapchat 2023 - Guide
- Count occurrences in excel - Guide
- Youtube subscriber count - Guide
3 responses
BunoCS
Posts
15493
Registration date
Monday July 11, 2005
Status
Moderator
Last seen
October 7, 2024
1,533
Oct 4, 2013 at 03:41 AM
Oct 4, 2013 at 03:41 AM
Hello,
Grammatically speaking, a sentence is terminated by a dot. If you want to count the number of sentences, you just have to count the number of dots
Here is a piece of code. Not tested but the idea is here
Note: I've renamed your variables to make sense
@+
Buno, Modo CS-CCM
The urgent is done, the impossible is underway. For miracles, envisage a time ...
Grammatically speaking, a sentence is terminated by a dot. If you want to count the number of sentences, you just have to count the number of dots
Here is a piece of code. Not tested but the idea is here
int main()
{
char paragraph[1000];
int nbChar, nbSentences;
// display prompt and get paragraph
clrscr();
printf("Enter your a paragraph\n\n\t: ");
gets(paragraph);
// get number of characters
nbChar = strlen(paragraph);
// read paragraph and count dot character
nbSentences = 0;
for (int i=0; i<nbChar; i++)
{
if (paragraph[i]=='.')
{
nbSentences++;
}
}
// display result
printf("\n\nTotal sentences: %d", nbSentences);
getch();
return 0;
}
Note: I've renamed your variables to make sense
@+
Buno, Modo CS-CCM
The urgent is done, the impossible is underway. For miracles, envisage a time ...