Skip to main content
Better information
Source Link
Tolani
  • 2.5k
  • 7
  • 30
  • 49

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output. This casts your answer to int
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be read once and it's outside your if statement
  • At this point, I will opt for a switch statement to make your main cleaner
  • To make this robust, you probably have to check for if invalid input was typed by the user

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output. This casts your answer to int
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be read once and it's outside your if statement
  • At this point, I will opt for a switch statement to make your main cleaner
  • To make this robust, you probably have to check for if invalid input was typed by the user

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be read once and it's outside your if statement
  • At this point, I will opt for a switch statement to make your main cleaner
  • To make this robust, you probably have to check for if invalid input was typed by the user
More explanation
Source Link
Tolani
  • 2.5k
  • 7
  • 30
  • 49

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output  . This truncates thecasts your answer to give only the integral part e.g if the result is 6.2, what is being printed out is 6int
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be written onlyread once and it's outside your if statement
  • At this point, I will opt for a switch statement to make your main cleaner
  • To make this robust, you probably have to check for exceptions e.g If anif invalid input was typed by the user

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output  . This truncates the answer to give only the integral part e.g if the result is 6.2, what is being printed out is 6
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be written only once
  • At this point, I will opt for a switch statement to make your main cleaner
  • To make this robust, you probably have to check for exceptions e.g If an invalid input was typed by the user

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output. This casts your answer to int
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be read once and it's outside your if statement
  • At this point, I will opt for a switch statement to make your main cleaner
  • To make this robust, you probably have to check for if invalid input was typed by the user
deleted 45 characters in body
Source Link
Tolani
  • 2.5k
  • 7
  • 30
  • 49

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output . This truncates the answer to give only the integral part e.g if the result is 6.2, what is being printed out is 6
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be written only once
  • At thethis point, I will opt for a caseswitch statement to make your main cleaner
  • To make this robust, you probably have to check for exceptions e.g If an invalid input was typed by the user
  • You don't need to make calls to main()

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output . This truncates the answer to give only the integral part e.g if the result is 6.2, what is being printed out is 6
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be written only once
  • At the point, I will opt for a case statement to make your main cleaner
  • To make this robust, you probably have to check for exceptions e.g If an invalid input was typed by the user
  • You don't need to make calls to main()

As I'm not a guru yet in C++, here are few pointers

  • Function names should start with lowercase letters e.g Minus() should be minus
  • There is no need to have int has a return type for your function. void is a valid return type and it means return nothing. This would save you the lines of return 0
  • Your divide and multiply functions may be prone to erroneous output . This truncates the answer to give only the integral part e.g if the result is 6.2, what is being printed out is 6
  • Avoid using namespace std because when you use additional libraries clashes may occur. Instead use qualified names e.g std::cout, std::endl etc
  • I see duplicate codes, DRY up your main function. Make first and second numbers global so this can be written only once
  • At this point, I will opt for a switch statement to make your main cleaner
  • To make this robust, you probably have to check for exceptions e.g If an invalid input was typed by the user
Source Link
Tolani
  • 2.5k
  • 7
  • 30
  • 49
Loading