Saturday, 5 March 2022

9. Write a program to check whether given number by the user is Palindrome or not.


#include<stdio.h>
#include<conio.h>

void main()
{
    long int no,temp,i,rem,rev=0;
    clrscr();

    printf("to check number palindrome or not");
    printf("\n\nenter number: ");
    scanf("%ld",&no);

    temp = no;

    for(i=0; no>0; i++)
    {
        rem = no % 10;
        rev = rev * 10 + rem;
        no = no / 10;
    }

    if(temp == rev)
    {
        printf("\n\nthis is palindrome number");
    }
    else
    {
        printf("\n\nthis is not palindrome number");
    }
    getch();
}

/*      output:

to check number palindrome or not

enter number: 1234321


this is palindrome number

*/ 

No comments:

Post a Comment

python programs

1. sum of two number