C Program to Reverse an Array or String - Source Code, Output & Execution Flow

C Program to Reverse an Array or String

This tutorial explains c program to reverse an array or string with C source code, sample output, and step-by-step execution flow.

#include <stdio.h>
int main() {
    int a[] = {1, 2, 3, 4, 5};
    int i;
    printf("Reversed array: ");
    for (i = 4; i >= 0; i--) printf("%d ", a[i]);
    return 0;
}
Reversed array: 5 4 3 2 1

In this program, the input is read first when required, the core logic is applied step by step, and the final result is displayed using printf(). Follow the execution flow beside the code to understand how each statement contributes to the output.