
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Program to print all palindromes in a given range in C++
In this tutorial, we will be discussing a program to print all palindromes in a given range.
For this we will be given the mathematical range in which the palindromes are to be found. Our task is to find all the palindromes in that range and print it back.
Example
#include<iostream> using namespace std; //checking if the number is a palindrome int is_palin(int n){ int rev = 0; for (int i = n; i > 0; i /= 10) rev = rev*10 + i%10; return (n==rev); } void countPal(int min, int max){ for (int i = min; i <= max; i++) if (is_palin(i)) cout << i << " "; } int main(){ countPal(99, 250); return 0; }
Output
99 101 111 121 131 141 151 161 171 181 191 202 212 222 232 242
- Related Articles
- Python Program to Print all Numbers in a Range Divisible by a Given Number
- Golang Program to Print all Numbers in a Range Divisible by a Given Number
- Python program to print all even numbers in a range
- Python program to print all odd numbers in a range
- Print all Good numbers in given range in C++
- Program to print prime numbers in a given range using C++ STL
- Golang Program to Print Odd Numbers Within a Given Range
- Python Program to Find All Numbers which are Odd and Palindromes Between a Range of Numbers
- Program to print all substrings of a given string in C++
- Python Program to print all permutations of a given string
- C Program to print all permutations of a given string
- Print prime numbers in a given range using C++ STL
- Java program to print all distinct elements of a given integer array in Java
- C# program to print all distinct elements of a given integer array in C#
- Print BST keys in the given range in C++

Advertisements