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;
}

No comments:

Software scope

 In software engineering, the software scope refers to the boundaries and limitations of a software project. It defines what the software wi...

Popular Posts