c++ program to reverse an array
#include<iostream>
using namespace std;
int main()
{
int a[]={1,2,3,4,5}; // Using Pointer and Array Relationship
for (int i = 4; i>=0; i--)
cout<<*(a+i);
return 0;
}
c++ program to reverse an array
#include<iostream>
using namespace std;
int main()
{
int a[]={1,2,3,4,5}; // Using Pointer and Array Relationship
for (int i = 4; i>=0; i--)
cout<<*(a+i);
return 0;
}
printing an array backwards in c++
#include <iostream>
// Print contents of an array in reverse order in C++
// using array indices
int main()
{
int arr[] = { 10, 20, 30, 40 };
size_t n = sizeof(arr)/sizeof(arr[0]);
// iterate backwards over the elements of an array
for (int i = n - 1; i >= 0; i--) {
std::cout << arr[i] << ' ';
}
return 0;
}
print array in reverse order
#include <stdio.h>
int main() {
int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
int loop;
for(loop = 9; loop >= 0; loop--)
printf("%d ", array[loop]);
return 0;
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us