Program Console Vignaankosh.com
Execution Panel
Console is empty.
Count frequency of each word is an interactive C dry run visualizer from the String Functions programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.
This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.
#include <stdio.h>
#include <string.h>
struct Word {
char word[50];
int count;
};
int main() {
char str[] = "the cat and the dog and the bird";
struct Word words[100];
int word_count = 0;
// Extract words
char *token = strtok(str, " ");
while(token != NULL) {
// Check if word already exists
int found = 0;
for(int i = 0; i < word_count; i++) {
if(strcmp(words[i].word, token) == 0) {
words[i].count++;
found = 1;
break;
}
}
// If new word, add to array
if(!found) {
strcpy(words[word_count].word, token);
words[word_count].count = 1;
word_count++;
}
token = strtok(NULL, " ");
}
// Display frequencies
for(int i = 0; i < word_count; i++) {
printf("%s: %d\n", words[i].word, words[i].count);
}
return 0;
}