69.0k views
4 votes
Q11. Write a full C++ program to solve the equation using function called solve, pass x,y as arguments to a function and returns 'z'

z=14x 3+8y 2+xy+3
Note: No I/O statements in the function.
Sample Run Enter x:2 Enter y:4 Z=251

User Muniro
by
8.3k points

1 Answer

3 votes

Final answer:

To solve the equation z = 14x^3 + 8y^2 + xy + 3 using a function called solve, you can write a C++ program that defines the solve function and uses it to calculate the value of z based on user input for x and y.

Step-by-step explanation:

To solve the equation z = 14x^3 + 8y^2 + xy + 3 using the function solve, you need to define a function that takes x and y as arguments and returns z. Here's an example of how you can write the C++ program:

#include
using namespace std;

int solve(int x, int y) {
int z = 14 * x * x * x + 8 * y * y + x * y + 3;
return z;
}

int main() {
int x, y;
cout << "Enter x: ";
cin >> x;
cout << "Enter y: ";
cin >> y;
int result = solve(x, y);
cout << "Z = " << result << endl;
return 0;
}

This program defines a function called solve that takes x and y as arguments and calculates the value of z. In the main function, the user is asked to enter the values of x and y, and the program calls the solve function to calculate and display the value of z.

User Karan Khanna
by
7.4k points