The Student Room Group

programming concepts and practices(introduction to c++)

Given an equation below:
𝐸 = −𝑚𝑒4 8𝑑2ℎ2𝑛2 where 𝑒 = 2.718

Complete the following code with the only provided function (void calculateEquation) to find the value of 𝑬 based on the value 𝑚, 𝑑, and 𝑛 correspondingly in the given array. The function shall perform the operation and no value needs to be returned as the result, 𝑬 is passed by reference. The value of 𝑬 must COUT in main function. No COUT in the function definition is allowed. #include <iostream> #include <cmath> using namespace std; //function prototype void calculateEquation(double [][4], int, double &); //2 nd parameter represents the index number of rows in the given array int main(){ double value[][4] = {{6.8, 2.1, 3.7, 5.0}, {3.2, 3.3, 8.3, 4.9}}; double E; //write your code over here. *hint: for-loop system("pause"); return 0; } //function definition void calculateEquation(/insert parameters here/){ //insert your statement(s) here }
Sample output: The value of E when m = 6.8, d = 2.1, h = 3.7 and n = 5 is -0.0307479 The value of E when m = 3.2, d = 3.3, h = 8.3 and n = 4.9 is -0.00121244
Reply 1
can anyone able to solve this question with perfect?I literally have no idea on how to start and do it...Help to solve it with cpp file,friends.....

Quick Reply

Latest

Trending

Trending