Program Console Vignaankosh.com
Execution Panel
Console is empty.
R13 Find last 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 lastOccurrence(int arr[], int n, int target, int index) {
if(index == n) {
return -1;
}
int position = lastOccurrence(arr, n, target, index + 1);
if(position != -1) {
return position;
}
if(arr[index] == target) {
return index;
}
return -1;
}
int main() {
int arr[] = {5, 3, 8, 3, 9, 8, 2};
int target = 8;
int pos = lastOccurrence(arr, 7, target, 0);
printf("Last %d at index %d\n", target, pos);
return 0;
}