Write a valid C math expression for the following algebraic
Solution
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.

