This repository was archived by the owner on May 29, 2024. It is now read-only.
Open
Conversation
|
Thanks for opening this pull request! Please check out our contributing guidelines. |
MdialloC19
suggested changes
Jan 17, 2024
MdialloC19
left a comment
There was a problem hiding this comment.
These modifications aim to provide more clarity to the user about what each output message represents. Feel free to adjust the messages further based on your specific preferences or requirements.
algorithms/C/maths/armstrong.c
Outdated
| temp/=10; // we extract a digit from number using (temp%10) then | ||
| } // raise that digit to number of digits in the number using pow function | ||
| // (pow()+0.5) is used to increase precision | ||
| printf("%d\n",sum); |
There was a problem hiding this comment.
must be more clear , printf("Sum of powered digits: %d\n", sum);
algorithms/C/maths/armstrong.c
Outdated
| digit++; //counting number of digits in the input number | ||
| temp=temp/10; | ||
| } | ||
| printf("%d\n",digit); |
There was a problem hiding this comment.
Must be more clear printf("Number of digits: %d\n", digit);
| printf("Not Armstrong"); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
You have to return something, if your return type is int. return 0
Author
There was a problem hiding this comment.
Added more clarity in print statements.
Author
|
Okay
…On Thu, 18 Jan 2024, 2:52 am MdialloC19, ***@***.***> wrote:
***@***.**** requested changes on this pull request.
These modifications aim to provide more clarity to the user about what
each output message represents. Feel free to adjust the messages further
based on your specific preferences or requirements.
------------------------------
In algorithms/C/maths/armstrong.c
<#1311 (comment)>
:
> + int num,digit=0,temp,sum=0; //define variables
+ printf("enter the number: ");
+ scanf("%d",&num); //taking inputs
+ temp=num;
+ while(temp>0){
+ digit++; //counting number of digits in the input number
+ temp=temp/10;
+ }
+ printf("%d\n",digit);
+ temp=num;
+ while(temp>0){
+ sum=sum+ (int)(pow(temp%10, digit)+0.5); // checking the armstrong property of the number
+ temp/=10; // we extract a digit from number using (temp%10) then
+ } // raise that digit to number of digits in the number using pow function
+ // (pow()+0.5) is used to increase precision
+ printf("%d\n",sum);
must be more clear , printf("Sum of powered digits: %d\n", sum);
------------------------------
In algorithms/C/maths/armstrong.c
<#1311 (comment)>
:
> +// an armstrong number is a number that equals the sum of its digits, each raised to a power.
+// power is the number of digits in the number eg. 123 has three digits, so power will be 3.
+
+#include<stdio.h>
+#include<math.h>
+
+int main(){ //main function
+ int num,digit=0,temp,sum=0; //define variables
+ printf("enter the number: ");
+ scanf("%d",&num); //taking inputs
+ temp=num;
+ while(temp>0){
+ digit++; //counting number of digits in the input number
+ temp=temp/10;
+ }
+ printf("%d\n",digit);
Must be more clear printf("Number of digits: %d\n", digit);
------------------------------
In algorithms/C/maths/armstrong.c
<#1311 (comment)>
:
> + printf("%d\n",digit);
+ temp=num;
+ while(temp>0){
+ sum=sum+ (int)(pow(temp%10, digit)+0.5); // checking the armstrong property of the number
+ temp/=10; // we extract a digit from number using (temp%10) then
+ } // raise that digit to number of digits in the number using pow function
+ // (pow()+0.5) is used to increase precision
+ printf("%d\n",sum);
+ if(num==sum){ //checking if the new number is equal to the input number
+ printf("Armstrong");
+ }
+ else{
+ printf("Not Armstrong");
+ }
+}
+
You have to return something, if you return type of the main is int. return
0
—
Reply to this email directly, view it on GitHub
<#1311 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/A65ND5MB7HPSFQKVUQESNL3YPA6HVAVCNFSM6AAAAABB224S5OVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQMRYGIYDCNZRHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Nothing-avil
approved these changes
Jan 19, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist:
What kind of change does this PR introduce? (check at least one)
Briefly describe the changes in this PR
This is algorithm is to find if a given number is Armstrong number or not. C language is used to implement it in this program.
Other information: