Computer Science, asked by drsagar3450, 10 months ago

Write a c++ programme to display all palindrome numbers between 100and200

Answers

Answered by sswaraj04
16

Answer:

#include <iostream>

using namespace std;

int main()

{

   cout<<"Palindrome numbers between 100 and 200 are"<<endl;

   for(int i=100;i<=200;i++)

   {

   int num=i,rev=0;

   do

    {

        int d = num % 10;

        rev = (rev * 10) + d;

        num = num / 10;

    } while (num != 0);

    if (i == rev)

        cout <<i<<"\t";

   }

   return 0;

}

Explanation:

Palindrome numbers are those numbers which on reversing the digits are same to original number.

so,we have to find reverse of the number

now on dividing by 10 and finding remainder gives our last digit.

so remainder will be stored in other variable and continously we will add the value to variable multiplying 10 to the number so that it adds to form new number

now we will check if reversed number is same to original or not

if equal we will print it.....

Hope it helps :-)

Similar questions