Program Console Vignaankosh.com
Execution Panel
Console is empty.
R12 Find first occurrence of an element (Recursion) is an interactive C dry run visualizer from the Recursion 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 firstOccurrence(int arr[], int n, int target, int index) {
if(index == n) {
return -1;
}
if(arr[index] == target) {
return index;
}
int position = firstOccurrence(arr, n, target, index + 1);
return position;
}
int main() {
int arr[] = {5, 3, 8, 3, 9, 8, 2};
int target = 8;
int pos = firstOccurrence(arr, 7, target, 0);
if(pos != -1)
printf("First %d at index %d\n", target, pos);
else
printf("%d not found\n", target);
return 0;
}