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++ 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
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].
Write a C program with call to functions to produce the output given below. // the...
Write a C program with call to functions to produce the output given below. // the requirements are that there should be 5 files; intList.h, intList.c, hw3.h, hw3.c, and main.c. please only C and use Linked List. thank you. For the 5 different files, he wants it this way: 1) main.c This file just consists of the main() function, which only consists of the displayClassInfo() function call, and the runMenuHw3() function call. 2) intList.h This file would have the IntNode...
Write a c program arrays2.c that checks if an integer array contains three identical consecutive elements....
Write a c program arrays2.c that checks if an integer array contains three identical consecutive elements. Assume the number of identical consecutive elements are no more than three if they exist. Sample input/output #1: Enter the length of the array: 11 Enter the elements of the array: -12 0 4 2 2 2 36 7 7 7 43 Output: The array contains 2 of three identical consecutive elements: 2 7 Sample input/output #2: Enter the length of the array: 4...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT