Soru
Write a complete C/C+C program which would calculate and display the result of the following equation. Y=e^a(a)/(sqrt (a^b)+sin(30))+ln(1000) Notice that, the a value WOULD NOT BE taken from the user and the b value will be taken from the user as an integer input. The a value will be randomly ganerated integer number be bewteen the range of -10 and -100 The program finds the value of Y according to the formula provided below and display the result on the screen as the output (30 pts.)
Çözüm
3.7
(317 Oylar)
İlayda
Elit · 8 yıl öğretmeni
Uzman doğrulaması
Cevap
Here's a C++ program that calculates the value of Y according to the given formula and displays the result on the screen:```cpp#include #include #include #include using namespace std;int main() { int a, b; float Y; // Generate a random integer for 'a' between -10 and -100 srand(time(0)); a = rand() % (-100 - (-10)) + (-10); // Take user input for 'b' as an integer cin >> b; // Calculate the value of Y according to the formula Y = exp(a) * a / sqrt(pow(a, b) + sin(30)) + log(1000); // Display the result on the screen cout << "The value of Y is: " << Y << endl; return 0;}```This program includes the necessary headers for input/output operations, mathematical functions, and time functions. It generates a random integer for 'a' between -10 and -100 using the `rand()` function and the `srand(time(0))` function to seed the random number generator. The user is prompted to enter the value of 'b' as an integer. The program then calculates the value of Y according to the given formula and displays the result on the screen using the `cout` statement.