Computer Science, asked by Sindhudevi2160, 10 months ago

Write a program to count number of word in a given file

Answers

Answered by mayanksharma789594
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