How to Write a C program to reverse an array elements using Dynamic Memory Allocation in C Programming Language ?
/*c program to reverse an array elements using Dynamic Memory Allocation*/
#include<stdio.h>
#include<conio.h>
void main()
{
int *ip,n,i;
int max=0;
clrscr();
printf("\nEnter the limit: ");
scanf("%d",&n);
ip=(int*)malloc(n*sizeof(int));
printf("\nEnter the elements:\n");
for(i=0;i<n;i++)
{
scanf("%d",&ip[i]);
}
printf("\nEntered elements are:\n");
for(i=0;i<n;i++)
{
printf("\n%d",ip[i]);
printf("\n");
}
printf("\nReverse array is:");
for(i=n-1;i>=0;i--)
{
printf("\n%d",ip[i]);
}
getch();
}
OUTPUT:
Enter the limit: 4
Enter the elements:
1
2
3
4
Entered elements are:1 2 3 4
Learn More :
Array
- How to pass one dimensional array to function in c.
- Write a c program which passes two dimension array to function.
- C Program Array Index Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program Array Example
- C Program to Array
- C Program Array NxM Elements Geometric/Arithmetic
- C Program To Find The Maximum And Minimum Value In An Array
- C Program To Find Union & Intersection Of Two Array
- C Program To Search A Number Inside The Array
- C Program To Sort An Array In Ascending And Descending Order
- C Program To Sort An Array Of Names In Alphabetical And Reverse Order
- C Program To Copy One Character Array Into Another
- Returns: array of decoded values. [0] - count of values
- C Program to Check if a number is in an array[1000]
- C Program to Find max and min in array using pointer concept
- C Program Sort Array By Segment
- C Program to sort an array using bubble sort
- C Program to find smallest in an array using pointer
- C Program to merge and sort two arrays
- Un-sortiertes Array and Sortiertes Array
- C Program to Array Deserialization
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- Input reads in the array positions and range for random generation.
Reverse
- C Program to Reverse a Word
- C Program Array Example: Reverse
- C Program To Find Reverse Of Any Digit Number
- C Program To Find The Length, Reverse Of A String And To Check It Is Palindrome or Not
- C Program To Reverse A Number
- C Program To Reverse The String Using Pointer
- C Program To Sort An Array Of Names In Alphabetical And Reverse Order
- C Program To Reverse A Given Number
- C Program To Reverse A Number
- C Program to Reversing a Five Digit Integer Number
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- Creation and Display of Elements in Both Forward and Reverse Direction in a Doubly Linked List
- Input Number and Print it's Reverse C Program
Element
- Given a numerical value, check if at least one of the elements of the vector is equal to the numerical value if so, say where in the negative case, say that there is no.
- C program to Given a vector (integer or real), determine what is the maximum value of element what is the position in which this element is located
- Write the procedure , which is one of a sum , a product and a geometric average in the panel for the NxM elements are located on opposite diagonal and main diagonal . Remind ! Counting only odd elements !
- Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.
- C Program Array NxM Elements Geometric/Arithmetic
- C Program To Returns the nth element of the Fibonacci sequence.
- C Program to search an element using linear search or binary search (menu driven program)
- Fibonacci Multi Threaded C Program To Print Element Of Fibonacci Series
- C Program to accept n numbers from user & find out the maximum element out of them by using dynamic memory allocation
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- C Program to accept n numbers from user store these numbers into an array & reverse an array elements using function
- C Program to accept 5 names from user & store these names into an array. Sort these array elements in alphabetical order
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
- C Program to Implemention Bubble Sort using array
- C Program to Create, Display, Insert and Deletion of Queue Elements
- Creation and Display of Elements in Both Forward and Reverse Direction in a Doubly Linked List
Dynamic Memory Allocation
- C Program to accept n numbers from user & find out the maximum element out of them by using dynamic memory allocation
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
- C Program Simple linked list