C Program to Print All Palindrome Numbers Between n and m using While loop
Write C Program to Print All Palindrome Numbers Between n and m using While loop
//Write a C program to print palindrome number between n and m using while loop #include <stdio.h> #include <stdbool.h> bool isPalindrome1(int n) { int temp = n, ans = 0; while(n != 0) { int remainder = n % 10; ans = ans * 10 + remainder; n = n / 10; } if(temp != ans) { return false; } return true; } int main() { int n,m; printf("Enter n :--> "); scanf("%d", &n); printf("Enter m :--> "); scanf("%d", &m); printf("Palindrome Numbers Between %d to %d :--> ", n, m); int i = n ,j = m; while(i < j) { if(isPalindrome1(i)) { printf("%d ",i); } i++; } return 0; }
Output:
Enter n :--> 5
Enter m :--> 78
Palindrome Numbers Between 5 to 78 :--> 5 6 7 8 9 11 22 33 44 55 66 77