Write a program that uses a function to check whether an entered three digit number is palindrome or not.
CODING:
#include<stdio.h>
#include<conio.h>
void palindrom(int n);
void main()
{
int no;
clrscr();
printf("\n Enhter The Number=");
scanf("%d",&no);
palindrom(no);
getch();
}
void palindrom(int n)
{
int temp,rev=0,rem;
temp=n;
while(n>=1)
{
rem=n%10;
n=n/10;
rev=rev*10+rem;
}
if(temp==rev)
{
printf("\n :) %d IS PALINDROM!",temp);
}
else
{
printf("\n :( %d IS NOT PALINDROM.",temp);
}
}
OUTPUT:
CODING:
#include<stdio.h>
#include<conio.h>
void palindrom(int n);
void main()
{
int no;
clrscr();
printf("\n Enhter The Number=");
scanf("%d",&no);
palindrom(no);
getch();
}
void palindrom(int n)
{
int temp,rev=0,rem;
temp=n;
while(n>=1)
{
rem=n%10;
n=n/10;
rev=rev*10+rem;
}
if(temp==rev)
{
printf("\n :) %d IS PALINDROM!",temp);
}
else
{
printf("\n :( %d IS NOT PALINDROM.",temp);
}
}
OUTPUT:
Comments
Post a Comment