- Full Information About Artificial Intelligence | What is AI?
- Most Common Important 70+ Shortcut Keyboard Keys
- Stars Square Pattern
- Fascinating Number or Not in C and CPP
- Implement queue using linked list c program
- Calculate the GCD | Euclidean algorithm | c and cpp programming language
- Linear search in c | Algorithm of Linear search | c programming
- A C program for checking whether a given line is a comment
- C program to convert decimal to binary without array
- Voting program in C language using switch case
- C program to check eligible for vote
- Insertion and deletion in double linked list in c program
- File read in C | File Handling | How to read File
- C program to replace vowels with special characters
- Call by Reference in C programming language
- Function call by value in c programming language
- Program to print a message without using semicolon in c programming
- User login system in c programming language
- How to make swastik in c and cpp programming language
- Print numbers from 1 to 100 using while loop c and cpp program
- Simple Macro Substitution(#define) in c and cpp programming language
- Insertion and Deletion of all operation at singly Linked list in c programming langauge
- Write a program to count the digit in a number
- Program to calculate the power of given numbers by user in c and cpp
- Sum of digit calculate program
- Write a program to reverse a number
- Floyd Triangle | Programs | Algorithm
- Program to check whether number is Disarium Number
- Sunny Number in programming
- Happy Number | with Example and Programs
- Display Name of the month by accepting digit of the month | c programming
- Spy Number | c programming
- 9 basic program in cpp programming language
- Automorphic number | c programming language
- C programming restaurant menu code lapmos
- Neon Number c programming language
- Strong Number in C programming What is Strong Number
- Leap Year | Leap year program in c
- Pascal Triangle C programming
- Check Palindrome Number in c
- Print Fibonacci Series in c
- Swap two number without using third variable c programming langauge
- Swap two number c programming
- Largest Number c programming language
- Prime number program in c
- What is the mean by Software Engineering?

A Number is a **disarium number** if the sum of the digits powered with their respective positions is equal to the number itself.

For Example:

89 is a Disarium number.

89: → 8^{1 }+ 9^{2 }= 8 + 81 = 89

```
#include <stdio.h>
#include<math.h>
int main()
{
int n, temp;
int sum = 0, count = 0;
printf("Enter a number : ");
scanf("%d", &n);
// First Count the digits of the number
temp = n;
while(temp!=0){
temp = temp/10;
count = count + 1;
}
temp = n;
while(count!=0){
int last_digit = temp%10;
temp = temp/10;
sum = sum + pow(last_digit,count);
count = count - 1;
}
if(sum == n){
printf("%d is a Disarium Number", n);
}else{
printf("%d is not a Disarium Number", n);
}
return 0;
}
```

```
// 175 = 1^1 + 7^2 + 5^3 = 1 + 49 + 125 = 50 + 125 = 175
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
int n, temp;
int sum = 0, count = 0;
cout<<"Enter a number : ";
cin>>n;
// First Count the digits of the number
temp = n;
while(temp!=0){
temp = temp/10;
count = count + 1;
}
temp = n;
while(count!=0){
int last_digit = temp%10;
temp = temp/10;
sum = sum + pow(last_digit,count);
count = count - 1;
}
if(sum == n){
cout<<n<<" is a Disarium Number";
}else{
cout<<n<<" is not a Disarium Number";
}
return 0;
```

- Calculate the length count digits of given number

a. Set temp = n

b. Use a while loop to check whether the number is not equal to 0.

c. Divide the number by 10 and increment the count by 1. - SET temp = n again
- Calculate the number of the given number

a. Use a while loop to check whether the count is not equal to 0.

b. Define and assign last_digit.

c. Calculate the last digit.

d. Remove the last digit by temp = temp / 10.

e. Calculate the sum = sum + pow(last_digit, count).

f. Decrement the count by 1. - Check the given number and sum

a. If the given number and sum is equal then PRINT “Given number is Disarium” otherwise go to step 2.

b. PRINT “Given number is not Disarium”- EXIT

🖤 0

Buy me coffee ☕

## Comments

Oops!