Write a valid C++ math expression for the following algebraic expressions. z/X +
ID: 3923956 • Letter: W
Question
Write a valid C++ math expression for the following algebraic expressions. z/X + Y - Y^22/Z - 3 X^14 - Y^3 (Z + Y)^9 Given the following program fragment: int a = 4; int b = 16 int c = 23; What is the value of each of the following expressions? a + c % a a/b * a + b c % b *a Programming Problems For each of the programming problems below answer the following questions: What does the program need to read in as input? Write the syntax to declare variables as needed to store what's being read in as input. What calculations does this program need to do? Write a valid C++ math expression that would perform the needed calculations. What does the program need to print as output?Explanation / Answer
Please follow the code and comments for description :
1)
a)
CODE :
#include <iostream> // required initialisations
#include <string>
#include <math.h>
using namespace std;
int main() // driver method
{
int x = 100, z = 600; // sample initialisations
int y = 1;
cout << (int)((z/(x + y)) - (pow(y, 22.0)/(z - 3))); // expression to calculate the data
}
OUTPUT :
4
b)
CODE :
#include <iostream> // required initialisations
#include <string>
#include <math.h>
using namespace std;
int main() // driver method
{
int x = 2, y = 2; // sample initialisations
cout << (int)(pow(x, 14) - pow(y, 3));// expression to calculate the data
}
OUTPUT :
16376
c)
CODE :
#include <iostream> // required initialisations
#include <string>
#include <math.h>
using namespace std;
int main() // driver method
{
int z = 1, y = 1; // sample initialisations
cout << (int)(pow((z + y), 9));// expression to calculate the data
}
OUTPUT :
512
2)
CODE :
#include <iostream> // required initialisations
#include <string>
#include <math.h>
using namespace std;
int main() // driver method
{
int a = 4, b = 16, c = 23;// sample initialisations
cout << "a + c % a is : " << a + c % a << endl; // expression to calculate the data
cout << "a / b * a + b is : " << a / b * a + b << endl;
cout << "c % b * a is : " << c % b * a << endl;
}
OUTPUT :
a + c % a is : 7
a / b * a + b is : 16
c % b * a is : 28
Hope this is helpful.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.