0% found this document useful (0 votes)
4 views1 page

Ass#2 Reverse Array

The document contains a C++ program that defines an array of integers and prints it in both original and reverse order. It initializes an array with five elements and calculates its size. The program uses loops to display the array elements in the specified orders.

Uploaded by

zayan aamir
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Ass#2 Reverse Array

The document contains a C++ program that defines an array of integers and prints it in both original and reverse order. It initializes an array with five elements and calculates its size. The program uses loops to display the array elements in the specified orders.

Uploaded by

zayan aamir
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: Muhammad Zayan

ID: 221372

#include <iostream>

using namespace std;

int main() {

int arr[] = {1, 2, 3, 4, 5};


int size = sizeof(arr) / sizeof(arr[0]);

cout << "Original array: ";


for (int i = 0; i < size; i++) {
cout << arr[i] << " ";
}
cout << endl;

cout << "Array in reverse order: ";


for (int i = size - 1; i >= 0; i--) {
cout << arr[i] << " ";
}

You might also like