Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Count the number of words in a string "C programming is fun".

Medium

Problem 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; }
Log in or sign up to run or submit your code.Log inSign up
Input
C programming is fun
Expected Output
Number of words: 4