#include<stdio.h>
int main()
{
int i, n, fact, sum = 0, copy, rem;
printf("Enter any positive integer number to check Krishnamurthi or Not\n");
scanf("%d",&n);
copy = n;
while(n > 0)
{
rem = n % 10;
fact = 1;
for(i = 1; i <= rem; i++)
fact = fact * i;
sum = sum + fact;
n = n / 10;
}
if(copy = = sum)
{
printf("%d given Number is Krishnamurthi",copy);
}
else
{
printf("%d Number is Not Krishnamurthi",copy);
}
return 0;
}
INPUT 1:
Enter any positive integer number to check Krishnamurthi or Not
145
OUTPUT 1:
145 Number is Krishnamurthi
INPUT 2:
Enter any positive integer number to check Krishnamurthi or Not
123
OUTPUT 2:
123 Number is Not Krishnamurthi
Monday, December 17, 2018
Home
/
C Programming
/
Simple Programs
/
WAP in C to check Whether a given Number is Krishnamurthi or Not
WAP in C to check Whether a given Number is Krishnamurthi or Not
Topics
# C Programming
# Simple Programs
About HindiKisseKahaniyaan
Easy Programming All is a free blogger to the students who wants to learn programming in C, HTML, CSS, Bootstrap, Web Designing from home. The students can learn programming free of cost at their home. We provide best logics about any program. If you want to ask any logic of any program you can comment to us in comment box.
Simple Programs
Labels:
C Programming,
Simple Programs
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment