8. Write a program to find the number is a happy number?
#include
#include
void main()
{
int a,r1,r2,b,x,r3,r4;
clrscr();
printf("enter the number");
scanf("%d",&a);
x=a;
r1=a%10;
r2=a%100;
r3=(r2-r1)/10;
r4=(a-r2)/100;
b=(r1*r1*r1)+(r3*r3*r3)+(r4*r4*r4);
if(b==x)
printf("happy number");
else
printf("not");
getch();
}
Algorithum
1.start
2.read a
3.calculate
r1=a%10
r2=a%100
r3=(r2-r1)/10
r4=(a-r2)/100
b=r1³+r3³+r4³
5.if b=x
6.print happy no
7.else
8.print not
9.stop
Result
The program is sucessfully excecuted and desired output is obtained.
Output
enter the no.
153
happy no
1 comments:
pikashow Picasso Apps is a video streaming platform from where you can watch TV Shows, Web Series, IPL Live, and the Latest Movies for free.
pikashow Picasso Apps is a video streaming platform from where you can watch TV Shows, Web Series, IPL Live, and the Latest Movies for free.
What is the Factorial of One Hundred Before diving into the depths of the factorial of one hundred, let us first grasp the concept of factorials.
Post a Comment