Skip to content

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

Open
archu5 wants to merge 1 commit intopclubuiet:masterfrom
archu5:master
Open

add c program to check for perfect numbers #71#92
archu5 wants to merge 1 commit intopclubuiet:masterfrom
archu5:master

Conversation

@archu5
Copy link
Copy Markdown

@archu5 archu5 commented Oct 19, 2018

issue #71 resolved

Comment thread 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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use proper indentation

Comment thread programs/C/perf.c Outdated
printf("hurray!,entered number is perfect\n");
}
else
printf("number is not perfect, try another one\n");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

indentation

Comment thread programs/C/perf.c Outdated
else
printf("number is not perfect, try another one\n");


Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

archu5 commented Oct 23, 2018

updated my code #71

Comment thread programs/C/per.c Outdated
if( sum == n)
{
printf("hurray!,entered number is perfect\n");
}else
Copy link
Copy Markdown
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.

Comment thread 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
Copy link
Copy Markdown
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.

Comment thread programs/C/perfe.c Outdated
#include<stdio.h>

int main()
{
Copy link
Copy Markdown
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

Comment thread programs/C/perfe.c Outdated
int main()
{
int sum = 0, n;
//prompting user for number to check whether it is perfect or not
Copy link
Copy Markdown
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.

Comment thread 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++)
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

move braces up

Comment thread 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
Copy link
Copy Markdown
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

Comment thread 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){
Copy link
Copy Markdown
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

Comment thread 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
Copy link
Copy Markdown
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
Copy Markdown
Author

archu5 commented Oct 25, 2018

made changes in code as suggested,please check.

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