-
Notifications
You must be signed in to change notification settings - Fork 62
add c program to check for perfect numbers #71 #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use proper indentation
programs/C/perf.c
Outdated
| printf("hurray!,entered number is perfect\n"); | ||
| } | ||
| else | ||
| printf("number is not perfect, try another one\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation
programs/C/perf.c
Outdated
| else | ||
| printf("number is not perfect, try another one\n"); | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unnecessary lines
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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++) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move braces up
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Present tense.
|
made changes in code as suggested,please check. |
sagar-kalra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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