bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / tuition-c / P050.c

P050.c (967B)


      1 /* Write a program to input a number and check whether it is Disarium Number or not.
      2     Note : A number is said to Disarium if sum of its digit powered by with their
      3     respective position is equal to the original number. */
      4 
      5 // This code has not been compiled.
      6 // If you find any issues, please create a new issue on GitHub regarding them.
      7 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
      8 
      9 #include <stdio.h>
     10 #include <math.h>
     11 
     12 int main()
     13 {
     14     int num, res = 0, temp, position = 0;
     15     printf("Enter the number : ");
     16     scanf("%d", &num);
     17     temp = num;
     18     while (temp > 0)
     19     {
     20         position++;
     21         temp /= 10;
     22     }
     23     temp = num;
     24     while (temp > 0)
     25     {
     26         res += (int)pow(temp % 10, position);
     27         position--;
     28         temp /= 10;
     29     }
     30     if (res == num)
     31         printf("\nInput %d is a Disarium Number.", num);
     32     else
     33         printf("\nInput %d is Not a Disarium Number.", num);
     34     return 0;
     35 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror