Question

In: Computer Science

C++ coding plase Given three integer numbers N1, N2 and N3. Write 2 overloaded functions which...

C++ coding plase

Given three integer numbers N1, N2 and N3. Write 2 overloaded functions which perform addition of passed values.

Write two functions inside 'ProblemSolution' class:

Function 1:

solution that accepts two parameters, N1 and N2. A function should return addition of those numbers.

Function 2:

solution that accepts three parameters, N1, N2 and N3. A function should return addition of 3 numbers.

Input
    2
    3
    4

Output
    5
    9

Where,

The first line of output contains addition of N1 and N2.

The second line of output contains addition of N1, N2 and N3.

using this code in the problem

#include <Iostream>

using namespace Std;

Class ProblemSolution

{

// write your code here

}:

int main()

{

int N1,N2,N3;

cin >> n1;

cin >> N2;

cin >> N3;

problemSolution problemSolution;

cout << problemSolution.solution(N!,N2)<<"\n" ;

cout << problemSolution.solution( N1,N2,N3);

return 0;

Solutions

Expert Solution

Solution :

#include <Iostream>
using namespace std;

class ProblemSolution
{
   // write your code here
   public:
       int solution(int a, int b) {
           return a + b;
       }
      
       int solution(int a, int b, int c) {
           return a + b + c;
       }
};

int main()
{
   int N1,N2,N3;
   cin >> N1;
   cin >> N2;
   cin >> N3;

   ProblemSolution problemSolution;
   cout << problemSolution.solution(N1,N2) << "\n" ;
   cout << problemSolution.solution(N1,N2,N3);

   return 0;
}


Note: There some minor Syntactical error in your code ,so i fix it please check it

Screenshot :


Related Solutions

If n1<n2 and n3<n2, which of the following statements are true when it comes to finding...
If n1<n2 and n3<n2, which of the following statements are true when it comes to finding out if you have destructive interference of the reflected rays? You do need to know if n1 is bigger or smaller than n3. You cannot make any calculations unless you know the numerical value of n3. You cannot make any calculations unless you know the numerical value of n2. The reflected ray from the interface between medium 1 and medium 2 will undergo a...
Write a C code program to implement the comparisons of three integer numbers, using only conditional...
Write a C code program to implement the comparisons of three integer numbers, using only conditional operators (no if statements). Please ask the user to input random three integers. Then display the minimum, middle, and maximum number in one line. Also, please calculate and display the sum and the average value (save two digits after decimal point) of these three integers. Please write the comments line by line.
Write a C++ program to read a collective of integer numbers. I f the number is...
Write a C++ program to read a collective of integer numbers. I f the number is greater than zero and less than 15 then terminate the loop and find factorial of the number
Write a C++ program that randomly generates N integer numbers (such that N is entered by...
Write a C++ program that randomly generates N integer numbers (such that N is entered by the user) and then stores them to a text file (myNumbers.txt) sorted in increasing (non-decreasing) order. Again, please notice that the size of the data (N) is known during the run time, not the compile-time (needs to be entered by the user after running the program).
(Do the algorithm and flowchart) Write a C++ program that reads integer numbers and print it...
(Do the algorithm and flowchart) Write a C++ program that reads integer numbers and print it in horizontal order of the screen
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers...
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers for height and width and uses a nested for loop to make a rectangle out of asterixes. The creation of the rectangle (i.e. the nested for loop) should occur in a void function that takes in 2 parameters, one for height and one for width. Make sure your couts match the sample output (copy and paste from those couts so you don't make a...
C coding • Implement, using structures and functions as appropriate, a program which requires you to...
C coding • Implement, using structures and functions as appropriate, a program which requires you to enter a number of points in 3 dimensions. The points will have a name (one alphanumeric character) and three coordinates x, y, and z. Find and implement a suitable way to stop the input loop. The program, through an appropriate distance function, should identify the two points which are the furthest apart. Another function should calculate the centre of gravity of the point cloud...
1. Write a Java program that prompts the user to enter three integer numbers. Calculate and...
1. Write a Java program that prompts the user to enter three integer numbers. Calculate and print the average of the numbers. 2. Write a Java program that uses a for loop to print the odd numbers from 1 to 20. Print one number per line in the command line window. 3. Write a program which asks the user to input the size of potatoe fries she would like to purchase, and based on the size, it will tell her...
c++ Write a program that will ask the user for three pairs of integer values. The...
c++ Write a program that will ask the user for three pairs of integer values. The program will then display whether the first number of the pair is multiple of the second. The actual work of making the determination will be performed by a function called IsMultiple that takes two integer arguments (say, x and y). The function will return a Boolean result of whether x is a multiple of y.
Write a C program that asks the user to enter 15 integer numbers and then store them in the array.
Write a C program that asks the user to enter 15 integer numbers and then store them in the array. Then, the program will find the second largest element in array and its index without sorting the array. For example, In this array {-55,-2,1, 2, -3, 0, 5, 9, 13, 1, 4, 3, 2, 1, 0}, the second largest element is 9 [found at index 7].
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT