Sunday 6 March 2022

C Program To Print All Palindrome Numbers in Given Range

 ALL PALINDROME NUMBERS


Code :

#include<stdio.h>

int main()
{
    int n,s, rev=0,count = 0, temp, rem;

    printf("========================================\n");
    printf("\tPALINDROME NUMBER\n");
    printf("========================================\n");

    printf("Instrunctions : \nPalindrome is an 3 digit number so please enter lower limit above 99.\n\n");
    printf("Enter lower limit of numbers : ");
    scanf("%d", &s);

    printf("Enter upper limit of numbers : ");
    scanf("%d", &n);
    printf("\n");

    if(s < 100)
    {
        s = 100;
    }

    printf("All Palindrome numbers between %d and %d are,\n", s, n);

    for(int i=s; i<=n; i++)
    {
        temp = i;
        rev = 0;
        while(temp != 0)
        {
            rem = temp%10;
            rev = (rev * 10) + rem;
            temp /= 10;
        }

        if(rev == i)
        {
            printf("%d ", i);
            count++;
        }
    }
    if(count == 0)
    {
        printf("\nNO ANY PALINDROME NUMBER IN GIVEN RANGE !!\n");
    }
    printf("\n----------------------------------------\n");
    return 0;
}


Come again Learn again !

« iCodeBuzz »


No comments:

Post a Comment