Computer Science, asked by tanurathor5311, 10 months ago

Write a user defined function reverse(int a[],int n) which accepts an integer array and its size as arguments(parameters) and reverse the array.

Answers

Answered by basavaraj5392
0

Answer:

Input : arr[] = {1, 2, 3}

Output : arr[] = {3, 2, 1}

Input : arr[] = {4, 5, 1, 2}

Output : arr[] = {2, 1, 5, 4}

Answered by Ᏸυէէєɾϝɭყ
4

Answer:

Explanation:

C++ For Loop:

Write a program in C++ to display the number in reverse order.

Sample Solution:-

C++ Códe :

#include <iostream>

using namespace std;

int main()

{

int num, r, sum = 0, t;

cout << "\n\n Display the number in reverse order:\n";

cout << "-----------------------------------------\n";

cout << " Input a number: ";

cin >> num;

for (t = num; num != 0; num = num / 10)

{

r = num % 10;

sum = sum * 10 + r;

}

cout << " The number in reverse order is : " << sum << endl;

}

Copy

Sample Output:

Display the number in reverse order:

-----------------------------------------

Input a number: 12345

The number in reverse order is : 54321

Similar questions