luc056.c¶
Problem Statement
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.
Metadata¶
| Property | Detail |
|---|---|
| Author | Amit Dutta amitdutta4255@gmail.com |
| Date | 08 Feb 2026 |
| License | MIT License (See the LICENSE file for details) |
Actions¶
💡 You can print or save this file by opening Raw and using your browser.
Source Code¶
#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;
}