Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651https://stackoverflow.com/a/12225214/4907651

  • You should keep return 0 for good practice

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651

  • You should keep return 0 for good practice

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: https://stackoverflow.com/a/12225214/4907651

  • You should keep return 0 for good practice

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

deleted 136 characters in body
Source Link
Ishaan
  • 484
  • 1
  • 3
  • 13

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651

  • I think you also forgot return 0at the end of main. Even though you have an infinite loop that exits the program within the loop using exit(n), having You should keep return 0 doesn't hurt.for good practice

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651

  • I think you also forgot return 0at the end of main. Even though you have an infinite loop that exits the program within the loop using exit(n), having return 0 doesn't hurt.

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651

  • You should keep return 0 for good practice

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

added 150 characters in body
Source Link
Ishaan
  • 484
  • 1
  • 3
  • 13

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651

  • I think you also forgot return 0at the end of main. Even though you have an infinite loop that exits the program within the loop using exit(n), having return 0 doesn't hurt.

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651

  • I think you also forgot return 0at the end of main. Even though you have an infinite loop that exits the program within the loop using exit(n), having return 0 doesn't hurt.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

The program looks so much better. Few more tips:

  • When someone divides by 0, instead of exiting the program, prompt them to re-enter the second number

  • I noticed you changed num1 num2 to int. If someone inputs a number with decimals, the program misbehaves. It's probably best to leave the variables as float.

  • You now also have a nested if-else loop instead of switch (case). I don't know how I feel about that. It probably doesn't matter, and people may disagree, but I'd go back to switch (case). It just looks neater and I find it to be the go-to way to work menus.

  • If someone enters wrong values for choice, the program still prompts the user for num1 and num2, then prints Enter correct number! Exiting program. If you had a switch (case) menu, you could add a default case that would automatically tell the user that the choice is incorrect and they need to pick a valid option

  • You should stick with int main(void) in C. See: http://stackoverflow.com/a/12225214/4907651

  • I think you also forgot return 0at the end of main. Even though you have an infinite loop that exits the program within the loop using exit(n), having return 0 doesn't hurt.

  • Too much (useless) commenting. You don't need to add a comment stating when the main starts or what the function does unless it's not obvious.

I do like how when you exit the program, you have exit(0) for when it exits by user command (successful execution), and exit(1) for when there is an error.

added 286 characters in body
Source Link
Ishaan
  • 484
  • 1
  • 3
  • 13
Loading
Source Link
Ishaan
  • 484
  • 1
  • 3
  • 13
Loading