Write a program to count number of word in a given file
Answers
Answered by
2
Explanation:
#include <stdio.h>
#include <string.h>
#include<conio.h>
void main()
{
clrscr();
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);
getch();
}
Similar questions
Music,
5 months ago
Math,
5 months ago
Psychology,
10 months ago
Physics,
10 months ago
Geography,
1 year ago