C Program To Check Number Is Palindrome Or Not Using for Loop
C Program To Check Number Is Palindrome Or Not Using for Loop

- #include <stdio.h>
- int main()
- {
- int number, a = 0, b;
- printf("Enter a number to check number is palindrome or not :- ");
- scanf("%d", &number);
- b = number;
- for (;b != 0;)
- {
- a = a * 10;
- a = a + b%10;
- b = b/10;
- }
- if (number == a)
- {
- printf("%d is a palindrome number.\n", number);
- }
- else
- {
- printf("%d is not a palindrome number.\n", number);
- }
- return 0;
- }
Output
Test-1
Enter a number to check number is palindrome or not :- 121
121 is a palindrome number.
Test-2
Enter a number to check number is palindrome or not :- 123
123 is not a palindrome number.
Enter a number to check number is palindrome or not :- 121
121 is a palindrome number.
Test-2
Enter a number to check number is palindrome or not :- 123
123 is not a palindrome number.
Comments