Skip to content
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

add c program to check for perfect numbers #71 #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

archu5
Copy link

@archu5 archu5 commented Oct 19, 2018

issue #71 resolved

}
}
//checking if sum of divisors is equal to entered number or not and then printing required output
if(sum==n)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use proper indentation

printf("hurray!,entered number is perfect\n");
}
else
printf("number is not perfect, try another one\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

else
printf("number is not perfect, try another one\n");


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary lines

@AkshayCHD
Copy link
Contributor

also reset --soft the commits into one

@archu5 archu5 force-pushed the master branch 2 times, most recently from a922160 to 217be62 Compare October 23, 2018 15:24
@archu5
Copy link
Author

archu5 commented Oct 23, 2018

updated my code #71

programs/C/per.c Outdated
if( sum == n)
{
printf("hurray!,entered number is perfect\n");
}else
Copy link
Contributor

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");
}
Copy link
Contributor

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.

#include<stdio.h>

int main()
{
Copy link
Contributor

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

int main()
{
int sum = 0, n;
//prompting user for number to check whether it is perfect or not
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Present tense for comments.

printf("please enter number to check whether it is perfect or not:");
scanf("%d", &n);
for( int i = 1; i <= n/2; i++)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move braces up

scanf("%d", &n);
for( int i = 1; i <= n/2; i++)
{
if( n%i == 0){ //finding sum of divisors of entered number
Copy link
Contributor

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

sum += i;
}
}//checking if sum of divisors is equal to entered number or not and then printing required output
if( sum == n){
Copy link
Contributor

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

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Present tense.

@archu5 archu5 changed the title added c program to check for perfect numbers #71 add c program to check for perfect numbers #71 Oct 25, 2018
@archu5
Copy link
Author

archu5 commented Oct 25, 2018

made changes in code as suggested,please check.

Copy link
Contributor

@sagar-kalra sagar-kalra left a 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

@archu5
Copy link
Author

archu5 commented Oct 25, 2018

resolved #71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants