#1. Write a simple c++ program in to calculate the area of a regular hexagon.
#2. Write a program to compute the following mathematical equation to find the value of Y;
Y= 4x3 + 8x2 + 9x-19 over(÷) |7-x3| + square root of 3x2 +19
#include <iostream>
double hexagon_area(double side)
{
return (pow(side, 2) * 3 * sqrt(3)) / 2;
}
double user_function(double x)
{
return (4 * pow(x, 3) + 8 * pow(x, 2) + 9 * x - 19) / (abs(7 - pow(x, 3)) + sqrt(3 * pow(x, 2) + 19));
}
int main()
{
//calculate the area of a regular hexagon example
std::cout << hexagon_area(5)<<std::endl;
//calculate the user_function example
std::cout << user_function(10) << std::endl;
return 0;
}
Comments
Thank you ☆☆☆☆☆☆☆☆
Leave a comment