luc056.c
Problem Statement
luc056.c
If an array arr contains n elements, then write a program to check if arr[0] = arr[n-1], arr[1] = arr[n-2] and so on.
Source Code
c
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
int arr[100], n, i, symmetric = 1;
printf("Enter number of elements (n): ");
scanf("%d", &n);
printf("Enter %d elements: ", n);
for (i = 0; i < n; i++)
{
scanf("%d", &arr[i]);
}
// Check symmetry
for (i = 0; i < n / 2; i++)
{
if (arr[i] != arr[n - 1 - i])
{
symmetric = 0;
break;
}
}
if (symmetric)
printf("\nThe array is symmetric (Palindrome).\n");
else
printf("\nThe array is NOT symmetric.\n");
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
● Author - Amit Dutta · Updated - 08 Feb 2026