Search
 
SCRIPT & CODE EXAMPLE
 

C

Program to print all palindromes in a given range

#include<iostream>
using namespace std;
 
// A function to check if n is palindrome
int isPalindrome(int n)
{
    // Find reverse of n
    int rev = 0;
    for (int i = n; i > 0; i /= 10)
        rev = rev*10 + i%10;
 
    // If n and rev are same, then n is palindrome
    return (n==rev);
}
 
// prints palindrome between min and max
void countPal(int min, int max)
{
    for (int i = min; i <= max; i++)
        if (isPalindrome(i))
          cout << i << " ";
}
 
// Driver program to test above function
int main()
{
    countPal(100, 2000);
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: create arrya of chars malloc 
C :: esp32 dhcp server 
C :: sqrt function in c 
C :: vifm preview images 
C :: binary sorting 
C :: working outside of application context 
C :: bool c++ 
C :: armstrong in c 
C :: hash function in c 
C :: declare and initialize a string in C 
C :: increment pointer value in c 
C :: c malloc 
C :: C #ifdef Directive 
C :: allintext:christie kiser filetype:log 
C :: cast from float to long c 
C :: how to change the smartart style to 3D polished in powerpoint 
C :: convert c code to assembly language 
C :: ask the user if they would like to do something again in C 
C :: C access global variable same name 
C :: error: ‘_Atomic’ does not name a type 
C :: curl ftp upload file to directory 
C :: Writing tests for API requests 
C :: how to initiate pointer array with null in c 
C :: add last in list c 
C :: changing data type in one line c program 
C :: why return 0 is written at the code end? 
C :: function declaration in c 
C :: i765 OPT filing fees october 2 
C :: linked list in c 
C :: c triangle check if triangle is 90 degrees 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =