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-017.c

APC-PRAC-017.c (728B)


      1 /* Write a program to check perfect number. */
      2 // File Name - amit0611202503.c (LAB), APC-PRAC-017.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, i, divisibleSum = 0;
     13     printf("Enter a number : ");
     14     scanf("%d", &num);
     15     for (i = 1; i <= num / 2; i++)
     16     {
     17         if (num % i == 0)
     18         {
     19             divisibleSum += i;
     20         }
     21     }
     22     if (divisibleSum == num)
     23         printf("\nInput %d ia a Perfect Number.", num);
     24     else
     25         printf("\nInput %d is NOT a Perfect Number.", num);
     26     return 0;
     27 }