/* Array order
reversal without using second array */
#include<stdio.h>
void main()
{
int arr[50], i, j,
num, temp;
clrscr();
printf("\n Enter
number of elements to be entered to the
array: ");
scanf("%d", &num);
printf("Enter
%d number of elements into array arr", num);
for (i = 0; i <
num; i++) {
scanf("%d", &arr[i]);
}
j = i - 1;
i = 0;
while (i < j) {
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
j--;
}
printf("\n Resultant
array after reversal : ");
for (i = 0; i <
num; i++) {
printf("%d
\t", arr[i]);
}
getch();
}
No comments:
Post a Comment