C

C Program For Finding Palindromes In A Given Range

In the previous tutorial, we learned how to determine whether or not a number is a palindrome. We will learn how to find palindrome numbers in a given range in this tutorial.

C program for generating palindrome numbers within a specified range

#include<stdio.h>
int main(){
   int num, rem, reverse_num, temp, start, end;

   printf("Enter the lower limit: ");
   scanf("%d",&start);

   printf("Enter the upper limit: ");
   scanf("%d",&end);

   printf("Palindrome numbers between %d and %d are: ",start,end);
   for(num=start;num<=end;num++){
      temp=num;
      reverse_num=0;
      while(temp){
         rem=temp%10;
         temp=temp/10;
         reverse_num=reverse_num*10+rem;
      }
      if(num==reverse_num)
         printf("%d ",num);
   }
   return 0;
}

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button