bsc

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

root / semester_1 / tuition-c / P050-SHORT.c

P050-SHORT.c (878B)


      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;
     15     printf("Enter the number : ");
     16     scanf("%d", &num);
     17     int position = printf("%d", num);
     18     int temp = num;
     19     int res = 0;
     20     while (temp > 0)
     21     {
     22         res += (int)pow(temp % 10, position);
     23         position--;
     24         temp /= 10;
     25     }
     26     if (res == num)
     27         printf(" is a Disarium Number.");
     28     else
     29         printf(" is Not a Disarium Number.");
     30     return 0;
     31 }
© 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