We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 80dd25b commit 4434274Copy full SHA for 4434274
1 file changed
programs/C/perfe.c
@@ -0,0 +1,19 @@
1
+#include<stdio.h>
2
+
3
+int main()
4
+ {
5
+ int sum = 0, n;
6
+ //prompting user for number to check whether it is perfect or not
7
+ printf("please enter number to check whether it is perfect or not:");
8
+ scanf("%d", &n);
9
+ for( int i = 1; i <= n/2; i++)
10
11
+ if( n%i == 0){ //finding sum of divisors of entered number
12
+ sum += i;
13
+ }
14
+ }//checking if sum of divisors is equal to entered number or not and then printing required output
15
+ if( sum == n){
16
+ printf("hurray!,entered number is perfect\n");
17
+ }else
18
+ printf("number is not perfect, try another one\n");
19
0 commit comments