add c program to check for perfect numbers #71#92
add c program to check for perfect numbers #71#92archu5 wants to merge 1 commit intopclubuiet:masterfrom
Conversation
programs/C/perf.c
Outdated
| } | ||
| } | ||
| //checking if sum of divisors is equal to entered number or not and then printing required output | ||
| if(sum==n) |
programs/C/perf.c
Outdated
| printf("hurray!,entered number is perfect\n"); | ||
| } | ||
| else | ||
| printf("number is not perfect, try another one\n"); |
programs/C/perf.c
Outdated
| else | ||
| printf("number is not perfect, try another one\n"); | ||
|
|
||
|
|
|
also reset --soft the commits into one |
a922160 to
217be62
Compare
|
updated my code #71 |
programs/C/per.c
Outdated
| if( sum == n) | ||
| { | ||
| printf("hurray!,entered number is perfect\n"); | ||
| }else |
There was a problem hiding this comment.
Still, indentation is not perfect.
programs/C/per.c
Outdated
| printf("hurray!,entered number is perfect\n"); | ||
| }else | ||
| printf("number is not perfect, try another one\n"); | ||
| } No newline at end of file |
There was a problem hiding this comment.
Try matching the open braces with the closing braces.
programs/C/perfe.c
Outdated
| #include<stdio.h> | ||
|
|
||
| int main() | ||
| { |
There was a problem hiding this comment.
Move braces in above line
programs/C/perfe.c
Outdated
| int main() | ||
| { | ||
| int sum = 0, n; | ||
| //prompting user for number to check whether it is perfect or not |
There was a problem hiding this comment.
Present tense for comments.
programs/C/perfe.c
Outdated
| printf("please enter number to check whether it is perfect or not:"); | ||
| scanf("%d", &n); | ||
| for( int i = 1; i <= n/2; i++) | ||
| { |
programs/C/perfe.c
Outdated
| scanf("%d", &n); | ||
| for( int i = 1; i <= n/2; i++) | ||
| { | ||
| if( n%i == 0){ //finding sum of divisors of entered number |
There was a problem hiding this comment.
no need for braces for single line statements/conditions
programs/C/perfe.c
Outdated
| sum += i; | ||
| } | ||
| }//checking if sum of divisors is equal to entered number or not and then printing required output | ||
| if( sum == n){ |
There was a problem hiding this comment.
braces not required, use indentation
programs/C/perfe.c
Outdated
| if( n%i == 0){ //finding sum of divisors of entered number | ||
| sum += i; | ||
| } | ||
| }//checking if sum of divisors is equal to entered number or not and then printing required output |
|
made changes in code as suggested,please check. |
sagar-kalra
left a comment
There was a problem hiding this comment.
Don't solve 2 issues in 1 PR.
That's why concept of branching is used.
You can read it about here https://git-scm.com/book/en/v1/Git-Branching-What-a-Branch-Is
|
resolved #71 |
issue #71 resolved