Computer Science, asked by mohit551050, 11 months ago

write a program in c++ to count number of words in c++ !! only right answer otherwise I'll report and not copied!⚠️⚠️​

Answers

Answered by Avni2348
0

Explanation:

*

* C Program to Count Number of Words in a given Text Or Sentence

*/

#include <stdio.h>

#include <string.h>

void main()

{

char s[200];

int count = 0, i;

printf("Enter the string:\n");

scanf("%[^\n]s", s);

for (i = 0;s[i] != '\0';i++)

{

if (s[i] == ' ' && s[i+1] != ' ')

count++;

}

printf("Number of words in given string are: %d\n", count + 1);

}

Answered by Anonymous
3

\tt\it\bf\it\Large\bm{\mathcal{\fcolorbox{blue}{white}{\blue{PROGRAM:-}}}}

_____________________________

# include<fstream.h>

#include<conio.h>

void main( )

{

clrscr( );

ifstream fin;

fin.open("out.txt");

char word[30];

int count = 0;

while ( ! fin.eof( ) )

{

fin>>word;

count++;

}

cout<<"Number of words in file is ";

cout<<count;

fin.close( );

getch( );

}

}____________________________

hope it helps ✌️✌️

Similar questions