palindrome_of_number.cpp File Reference

Check if a number is palindrome or not. More...

`#include <algorithm>`
`#include <iostream>`
`#include <cstring>`
Include dependency graph for palindrome_of_number.cpp:

## Functions

int | main ()

## Detailed Description

Check if a number is palindrome or not.

This program cheats by using the STL library's std::reverse function.

## Function Documentation

## main()

int main | ( | void |  | ) |

Main function

{
int num;
std::cout << "Enter number = ";
std::cin >> num;
std::string s1 = std::to_string(num); // convert number to string
std::string s2 = s1;
std::reverse(s1.begin(), s1.end()); // reverse the string
if (s1 == s2) // check if reverse and original string are identical
std::cout << "true";
else
std::cout << "false";
return 0;
}
std::cin
std::cout
std::string
std::string::begin
T begin(T... args)
std::string::end
T end(T... args)
std::reverse
T reverse(T... args)
std::to_string
T to_string(T... args)
Here is the call graph for this function: