#include<stdio.h> #include<math.h> int main() { int i,j,num,temp,sum=0; printf("Enter number\n"); scanf("%d",&num); while(sum!=1 && sum!=4) { sum=0; while(num>0) { j=num%10; sum+=(j*j); num=num/10; } num=sum; } if(sum==1) printf("Happy Number\n"); else printf("UnHappy Number\n"); }
Showing posts with label Happy number. Show all posts
Showing posts with label Happy number. Show all posts
Thursday, 11 February 2021
Program to print weather the number is happy or not.
Subscribe to:
Comments (Atom)
Search This Blog
Labels
- Happy number
- Projects in C
About Me
Program to print weather the number is happy or not.
#include <stdio.h> #include <math.h> int main () { int i , j , num , temp , sum = 0 ; printf ( "Enter number\n...