-
Notifications
You must be signed in to change notification settings - Fork 2
Update add_2_integers.c #1
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,20 +2,22 @@ | |
#include <stdio.h> | ||
|
||
// start of the main function | ||
int main(void) | ||
{ | ||
printf("Starting the program here: \n"); | ||
|
||
int integer1, integer2; // first and second number to be entered by the user | ||
// int integer2; // second number to be entered by the user | ||
|
||
printf("Enter the first Integer:\n"); //prompt | ||
scanf("%d", &integer1); // read the integer | ||
|
||
printf("Enter the second Integer:\n"); //prompt | ||
scanf("%d", &integer2); // read the second integer | ||
|
||
int sum = integer1 + integer2; // assign the value of the total expression to sum | ||
printf("Sum is %d\n", sum); | ||
|
||
}// end of the main function | ||
int main() { | ||
int a, b, sum; | ||
|
||
// Get the first integer from the user | ||
printf("Enter the first integer: "); | ||
scanf("%d", &a); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, i would argue that beginners be introduce to naming variables as meaningful constructs, since this doesn't offer any technical improvement over the previous structure, it is not an update , so we can stick with the longer variable names, nice work though 👌 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay I understand that and thank you for your feedback. |
||
|
||
// Get the second integer from the user | ||
printf("Enter the second integer: "); | ||
scanf("%d", &b); | ||
|
||
// Add the two numbers | ||
sum = a + b; | ||
|
||
// Display the result | ||
printf("The sum of %d and %d is %d\n", a,b, sum); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥🔥🔥🔥 |
||
|
||
return 0; | ||
}// end of the main function |
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.
Keep in mind, that this codebase is intended for readers looking to learn C, so some obvious redundant efforts are actually intentionally, this include the print line here to let the user observe the start of the program execution.
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.
Okay purely understand that, many people have problems on many things. Thank you for your feedback, I appreciate that 🙏