PROGRAM:
#include<stdio.h>
#include<math.h>
main()
{
int a,i,sum=0,n,ch,m;
printf("\nEnter
a Number\n"); scanf("%d",&a);
printf("\n1.Palindrome\n2.Armstrong\n3.Prime\n");
printf("\nEnter the Choice:\n");
scanf("%d",&ch);
switch(ch)
{
case 1:
n=a;
while(a>0)
{
i=a%10;
sum=(sum*10)+i;
a=a/10;
}
if(n==sum)
printf("Given Number is
Palindrome\n");
else
printf("Given Number is Not
Palindrome\n"); break;
case 2:
n=a;
do
{
i=a%10; sum=sum+(i*i*i); a=a/10;
}while(a>0);
if(n==sum)
printf("Given Number is
Armstrong\n");
else
printf("Given Number is Not
Armstrong\n");
break; case 3:
m=5;
n=sqrt(a);
for(i=2;i<=n;i++)
{
if(a%i==0)
{
m=0;
break;
}
}
if(m==0)
printf("Given
Number is Prime\n");
else
printf("Given
Number is Not Prime\n");
break;
}
}
OUTPUT:
Enter
a Number 121 1.Palindrome 2.Armstrong 3.Prime
Enter
the Choice: 1
Given Number is Palindrome
No comments:
Post a Comment