Answer to Question #180163 in C++ for Abdul Rajjak

Question #180163

Create a class: “Palindrome” with private data members: upper_limit (int), lower_limit (int) and parameterized constructor, which initializes the values of both data members. Apart from initialization, this constructor also displays the count of palindrome numbers from upper_limit to lower_limit. [Example: upper_limit:50, lower_limit:10, count of palindrome numbers is: 4(11 , 22, 33 and 44), also make sure the value of upper_limit should be greater than lower_limit]. 


1
Expert's answer
2021-04-12T04:53:40-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS