programming9
  • Flowcharts
  • Programs
      • Back
      • C Programs
      • C++ Programs
      • Java Programs
      • Python Codes
      • HTML Codes
      • Java Script Codes
      • SQL Codes
  • Tutorials
      • Back
      • Java Tutorials
      • Competitive Programming
      • Python Tutorials
      • C Programming
  • Blog
  • Login

C Program to Reverse Elements in Array

Details
Written by: RajaSekhar
Category: C Programs
  • Arrays in C
#include<stdio.h>
int main()
{
	int n, i, j, *p, a[10], b[10];
	printf("Enter the number of elements :: ");
	scanf("%d", &n);



	printf("Enter the elements : ");
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}

	//REVERSING THE ARRAY

	p=a;
	for(i = 0, j = n-1; i < n; i++, j--)
	{
		b[i] = *(p+j);
	}
	printf("The reversed array :: ");

	for(i = 0; i < n; i++)
		printf("%d  ", b[i]);

	printf("\n");
	return 0;
}

 OUTPUT:

Enter the number of elements :: 6
Enter the elements : 10 20 30 40 50 60
The reversed array :: 60  50  40  30  20  10

Previous article: C Program for MERGING of Two Arrays with out using Third Array Prev Next article: C Program to Perform Operations on Doubly Linked List Next
  • C Program to Print Hello World
  • C Program to Check the Leap Year
  • C Program to Calculate Sum of Odd Values in an Array
  • C Program to Find Area of Rectangle
  • C Program for Arithmetic Operations using Switch Statement
  • C Program to Find Area of a Triangle
  • C Program to Copy Contents From One File to Another
  • C Program to Print Elements of Array Using Pointers
  • C Program to Implement Call By Value using Functions
  • C Program to find Reverse of a Number
  • C Program for String Comparison without using Built in Function
  • C Program to Simulate PRIORITY CPU Scheduling Algorithm
  • C Program Example to Initialize Structure Variable
  • C Program to Find Prime Factors of a Given Positive Number
  • C Program for Quick Sort
  • Privacy Policy
  • Cookie Policy
© programming9.com 2025
Back to top