bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / luc056.c

luc056.c (894B)


      1 /* 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.
      2 */
      3 
      4 /* Let Us C, Chap- 13 (Arrays), Qn No.: B(b) */
      5 
      6 /* This file is auto-generated by a bot. */
      7 /* This code is not compiled; it is for reference only. */
      8 
      9 
     10 #include <stdio.h>
     11 #include <math.h>
     12 #include <stdlib.h>
     13 
     14 int main()
     15 {
     16     int arr[100], n, i, symmetric = 1;
     17 
     18     printf("Enter number of elements (n): ");
     19     scanf("%d", &n);
     20 
     21     printf("Enter %d elements: ", n);
     22     for (i = 0; i < n; i++)
     23     {
     24         scanf("%d", &arr[i]);
     25     }
     26 
     27     // Check symmetry
     28     for (i = 0; i < n / 2; i++)
     29     {
     30         if (arr[i] != arr[n - 1 - i])
     31         {
     32             symmetric = 0;
     33             break;
     34         }
     35     }
     36 
     37     if (symmetric)
     38         printf("\nThe array is symmetric (Palindrome).\n");
     39     else
     40         printf("\nThe array is NOT symmetric.\n");
     41 
     42     return 0;
     43 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror