" this is a test "
4
#include <stdio.h>
int main() {
char str[200];
int i;
int count = 0;
printf("Enter a sentence: ");
fgets(str, sizeof(str), stdin);
for (i = 0; str[i] != '�'; i++) {
// Word start condition
if (str[i] != ' ' &&
(i == 0 || str[i - 1] == ' ')) {
count++;
}
}
printf("Number of words = %dn", count);
return 0;
}
#include <stdio.h>
int main() {
char str[200];
int i;
int count = 0;
printf("Enter a sentence: ");
fgets(str, sizeof(str), stdin);
for (i = 0; str[i] != '�'; i++) {
// Word start condition
if (str[i] != ' ' &&
(i == 0 || str[i - 1] == ' ')) {
count++;
}
}
printf("Number of words = %dn", count);
return 0;
}