C program to reverse the elements of an array

Simple C program to reverse elements of an array

Code:

#include<stdio.h>

#include<conio.h>

void main()

{

int n,a[10],i,j,e;

clrscr();

printf("enter limit : ");

scanf("%d",&n);

for(i=0;i<n;i++)

{

printf("Enter number of a[%d] : ",i);

scanf("%d",&a[i]);

}



for(i=0,j=n-1;i<n/2;i++,j--)

{

e=a[i];

a[i]=a[j];

a[j]=e;

}

Printf(“Reversed string: “);

for(i=0;i<n;i++)

{

printf("\n %d ",a[i]);

}



getch();

}

Comments

Popular posts from this blog

C program to evaluate Prefix Expression using Stack data structure

Java Program to Implement sorting algorithm using TCP on Server application

C++ program to perform data transformation Min-max and Z score Normalization