pc011.c ​
Metadata ​
- Author — Amit Dutta
- Last updated — 12 Dec 2025
- License — MIT License (See the LICENSE file for details)
Problem Statement ​
Problem Statement
Write a C program that takes two positive integers, L (Lower Bound) and U (Upper Bound), as input from the user. The program must find and print the count of all numbers between L and U (inclusive) that are also a Palindrome Number.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#define true 1
#define false 0
int isPalindrome(int num)
{
int temp = num, numRev = 0;
while (temp > 0)
{
numRev = (numRev * 10) + (temp % 10);
temp /= 10;
}
if (num == numRev)
return true;
else
return false;
}
int main()
{
int uBound, lBound, num, palindromeCount = 0;
printf("Enter the Lower Bound and Upper Bound : ");
if (scanf("%d %d", &lBound, &uBound) != 2)
{
printf("\nOnly Integer values are allowed.");
return 1;
}
if (lBound < 0 || uBound < 0 || lBound > uBound)
{
printf("\nPlease enter appropriate inforamtion.");
return 1;
}
printf("Palindrome Numbers from %d to %d :", lBound, uBound);
for (num = lBound; num <= uBound; num++)
{
if (isPalindrome(num))
{
printf(" %d", num);
palindromeCount++;
}
}
printf("\nTotal Palindrome number found inside the range (%d to %d) : %d", lBound, uBound, palindromeCount);
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
35
36
37
38
39
40
41
42
43
44
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
35
36
37
38
39
40
41
42
43
44