Question: A piece of code you wrote in previous years caught your eye. You realize after a long time that you wrote this piece of code

A piece of code you wrote in previous years caught your eye. You realize after a long time that you wrote this piece of code to calculate the average of your two marks on the exam.

A piece of code you wrote in previous years caught your eye.

Whether 1: Rewrite your code according to the clean-code naming principles.

Whether 2: Due to the Single Responsibility Principle, which is one of the clean-code principles, each function should only do one job. What does this function do?

Re-code this function by refactoring according to the single responsibility principle.

1 # include 2 3 void get_average() 4 { 5 int x; int y; 6 7 8 std::cin>>x; std::cin>>y; int result = (x + y)/2; ; = std::cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!