Showing posts with label program for printing all palindromes upto entered number. Show all posts
Showing posts with label program for printing all palindromes upto entered number. Show all posts

Saturday, April 23, 2022

program for printing all palindromes upto entered number

 #include <iostream>

using namespace std;
#include <conio.h>

class pal
{
    int num1;

public:
    int reverse, rem, i, j, reverse1;
    pal(int num1)
    {
        this->num1 = num1;
    }
    void check()
    {
        if (num1 > 0)
        {
            for (i = 1; i <= num1; i++)
            {
                j = i;
                reverse = 0;

                while (j)
                {
                    rem = j % 10;
                    reverse = reverse * 10 + rem;
                    j = j / 10;
                }

                if (i == reverse)
                {
                    cout << i << endl;
                }
            }
        }
        else
            cout << "number entered is less than 1\n";
    }
};
int main()
{
    system("cls");
    int num1;
    cout << "enter number upto which you want palindromes\n";
    cin >> num1;
    pal a(num1);
    system("cls");
    cout << "palindromes upto " << num1 << endl;
    a.check();

    return 0;
}

HackCache ’26: A 48-Hour Online Hackathon Open to Every Student

  Hackathons are often associated with computer science students, experienced developers, and teams that already know exactly what they are...

Popular Posts