-
Notifications
You must be signed in to change notification settings - Fork 14
/
palindrome and armstrong numbers
61 lines (59 loc) · 1.17 KB
/
palindrome and armstrong numbers
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
int main()
{
printf("***menu*** \n");
printf("***choose 1 for palindrome number*** \n");
printf("***choose 2 for armstrong number*** \n");
int ch;
printf("enter your choice: ");
scanf("%d",&ch);
if(ch==1)
{
int reverse=0;
int num,a,r;
printf("enter any number:");
scanf("%d",&num);
a=num;
while(a>0)
{
r=a%10;
reverse=reverse*10+r;
a=a/10;
}
if (reverse==num)
{
printf("it is a palindrome number");
}
else
{
printf("it is not a palindrome number");
}
}
else if(ch==2)
{
int sum=0;
int num,a,r;
printf("enter the 3 digit number:");
scanf("%d",&num);
a=num;
while(a>0)
{
r=a%10;
sum=sum+(r*r*r);
a=a/10;
}
if (sum==num)
{
printf("it is a armstrong number");
}
else
{
printf("it is not a armstrong number");
}
}
else
{
printf("invalid choice");
}
return 0;
}