bsc

Comprehensive codebase and coursework for the 4-year B.Sc. Computer Science Honours degree (WBSU)

git clone https://github.com/notamitgamer/bsc.git
· rebuilt hourlyOpen on GitHub
root / semester_1 / tuition-c / APC-PRAC-021.c

APC-PRAC-021.c (884B)


      1 /* Write a program to check special number (sum of digit + product of digit = original number) */
      2 // File Name - amit0711202503.c (LAB), APC-PRAC-021.c (Local)
      3 
      4 // This code has not been compiled.
      5 // If you find any issues, please create a new issue on GitHub regarding them.
      6 // Go to this link to create a new issue: https://github.com/notamitgamer/bsc/issues
      7 
      8 #include <stdio.h>
      9 
     10 int main()
     11 {
     12     int num, temp, sumOfDigit = 0, productOfDigit = 1;
     13     printf("Enter the number to check if it is a special number : ");
     14     scanf("%d", &num);
     15     temp = num;
     16     while (temp > 0)
     17     {
     18         sumOfDigit += temp % 10;
     19         productOfDigit *= temp % 10;
     20         temp /= 10;
     21     }
     22     temp = sumOfDigit + productOfDigit;
     23     if (num == temp)
     24         printf("\nInput %d is a special number.", num);
     25     else
     26         printf("\nInput %d is not a special number.", num);
     27     return 0;
     28 }