bsc

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

pc011.c (1478B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 12 Dec 2025
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a C program that takes two positive integers, L (Lower Bound)
      9 and U (Upper Bound), as input from the user. The program must find and print
     10 the count of all numbers between L and U (inclusive) that
     11 are also a Palindrome Number. */
     12 
     13 #include <stdio.h>
     14 #define true 1
     15 #define false 0
     16 
     17 int isPalindrome(int num)
     18 {
     19     int temp = num, numRev = 0;
     20     while (temp > 0)
     21     {
     22         numRev = (numRev * 10) + (temp % 10);
     23         temp /= 10;
     24     }
     25     if (num == numRev)
     26         return true;
     27     else
     28         return false;
     29 }
     30 
     31 int main()
     32 {
     33     int uBound, lBound, num, palindromeCount = 0;
     34     printf("Enter the Lower Bound and Upper Bound : ");
     35     if (scanf("%d %d", &lBound, &uBound) != 2)
     36     {
     37         printf("\nOnly Integer values are allowed.");
     38         return 1;
     39     }
     40     if (lBound < 0 || uBound < 0 || lBound > uBound)
     41     {
     42         printf("\nPlease enter appropriate inforamtion.");
     43         return 1;
     44     }
     45     printf("Palindrome Numbers from %d to %d :", lBound, uBound);
     46     for (num = lBound; num <= uBound; num++)
     47     {
     48         if (isPalindrome(num))
     49         {
     50             printf("  %d", num);
     51             palindromeCount++;
     52         }
     53     }
     54     printf("\nTotal Palindrome number found inside the range (%d to %d) : %d", lBound, uBound, palindromeCount);
     55     return 0;
     56 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror