About 2,830,000 results
Open links in new tab
  1. Array Reverse – Complete Tutorial - GeeksforGeeks

    Sep 25, 2024 · // C++ Program to reverse an array using Recursion #include <iostream> #include <vector> using namespace std; // recursive function to reverse an array from l to r void reverseArrayRec (vector < int > & arr, int l, int r) {if (l >= r) return; // Swap the elements at the ends swap (arr [l], arr [r]); // Recur for the remaining array ...

  2. Reversal algorithm for Array rotation - GeeksforGeeks

    Apr 6, 2023 · Given an array arr [] of size N, the task is to rotate the array by d position to the left. Examples: it becomes {2, 3, 4, 5, 6, 7, 1}. Approach: We have already discussed several methods in this post. The ways discussed there are: Using another temporary array. Rotating one by one. Using a juggling algorithm.

  3. Reverse Array in C - GeeksforGeeks

    Nov 20, 2024 · The simplest method to reverse an array in C program is by using two pointers: one starting at the beginning (left) and one at the end (right) of the string. Swap the elements at these pointers while moving them towards centre of the array until the pointers meet.

  4. C Program to Reverse an Array - W3Schools

    Given below is the c code to reverse an array. * Copying elements into array b starting from end of array a. */ for (c = n - 1, d = 0; c >= 0; c --, d ++) . b [d] = a [c]; /* * Copying reversed array into original. * Here we are modifying original array, this is optional. */ for (c = 0; c < n; c ++) .

  5. C program to find reverse of array - Codeforwin

    Jul 17, 2015 · Write a C program to input elements in array and find reverse of array. How to find reverse of array in C programming. Logic to find reverse of array in C program. Basic Input Output, For loop, While loop, Array. There are various ways to reverse an array. Here I will explain the basic three algorithms to reverse a given array.

  6. C Program to Reverse an Array | Scaler Topics

    Dec 18, 2022 · In C, there are no inbuilt functions to reverse an array, we have to write the code for it on our own. An array can be reversed using different methods and algorithms - printing it from the last element, using an auxiliary array, recursion, swapping, etc.

  7. C Program to Reverse an Array - TechCrashCourse

    Here is the C program to reverse an array with and without using temporary array. Given an array of integers of length N, we have to reverse the sequence of array elements. The first element of array should become the last element and vice versa.

  8. Reverse an Array in C - Sanfoundry

    Here is a C program to reverse an array using loops, recursion, function, and, Pointers, along with explanation and examples.

  9. C Program to Reverse an Array Elements - Online Tutorials Library

    In this article, we looked at three ways to reverse an array in C: using a temporary array (easy but needs extra space), using two pointers (fast and doesn't need extra space), and using recursion (clean but less efficient for large arrays).

  10. C Program for Reversal algorithm for array rotation

    Oct 10, 2023 · Write a function rotate(arr[], d, n) that rotates arr[] of size n by d elements. Example: Input: arr[] = [1, 2, 3, 4, 5, 6, 7] d = 2 Output: arr[] = [3, 4, 5, 6, 7, 1, 2] Rotation of the above array by 2 will make array. Algorithm : rotate(arr[], d, n) reverse(arr[], 1, d) ; reverse(arr[], d + 1, n); reverse(arr[], 1, n);

  11. Some results have been removed
Refresh