C Program to reverse elements of 1D array

#include<stdio.h>

#include<conio.h>

#define N 10

void main(){

int list[N],i,j,temp;

clrscr();

printf("Enter elements of List\n");

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

{

printf("%d element=",i+1);

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

}

printf("List Array is:\n");

for(i=0;i<N;i++){

printf("%d ",list[i]);

}

for(i=0,j=N-1;j>i; j--,i++){

temp=list[i];

list[i]=list[j];

list[j]=temp;

}

printf("Reversal of List Array is:\n");

for(i=0;i<N;i++){

printf("%d ",list[i]);

}

getch();

}

No comments:

Post a Comment