Program Console Vignaankosh.com
Execution Panel
Console is empty.
Compare two strings using function is an interactive C dry run visualizer from the 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>
int compareStrings(char str1[], char str2[]) {
int i = 0;
while(str1[i] != '\0' && str2[i] != '\0') {
if(str1[i] != str2[i]) {
return str1[i] - str2[i];
}
i++;
}
return str1[i] - str2[i];
}
int main() {
char strA[] = "Apple";
char strB[] = "Apple";
char strC[] = "Apricot";
char strD[] = "Banana";
if(compareStrings(strA, strB) == 0)
printf("strA and strB are EQUAL\n");
else
printf("strA and strB are DIFFERENT\n");
printf("strA vs strC: %d\n", compareStrings(strA, strC));
printf("strA vs strD: %d\n", compareStrings(strA, strD));
return 0;
}