Count the number of words in a string "C programming is fun".
MediumProblem Statement
Count the number of words in a string "C programming is fun".
Sample Input
C programming is fun
Sample Output
Number of words: 4
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <stdio.h>
#include <string.h>
int countWords(char str[]) {
// Your code here
}
int main() {
char str[] = "C programming is fun";
printf("Number of words: %d\n", countWords(str));
return 0;
}
Input
C programming is fun
Expected Output
Number of words: 4