given array and reversing array element used while loop in c
Answers
Explanation:
given array and reversing array element used while loop in c
Reverse array in C using for loop
Reverse array C program
#include <stdio.h>
int main()
{
int n, c, d, a[100], b[100];
printf("Enter the number of elements in array\n");
scanf("%d", &n);
printf("Enter array elements\n");
for (c = 0; c < n ; c++)
Explanation:
/**
* C program to print array in reverse order
*/
#include <stdio.h>
#define MAX_SIZE 100 // Defines maximum size of array
int main()
{
int arr[MAX_SIZE];
int size, i;
/* Input size of array */
printf("Enter size of the array: ");
scanf("%d", &size);
/* Input array elements */
printf("Enter elements in array: ");
for(i=0; i<size; i++)
{
scanf("%d", &arr[i]);
}
/*
* Print array in reversed order
*/
printf("\nArray in reverse order: ");
for(i = size-1; i>=0; i--)
{
printf("%d\t", arr[i]);
}
return 0;
}