i just need number 2 i use c++ Programs Due 4/25 17 (50% of testl The following
ID: 3825071 • Letter: I
Question
i just need number 2 i use c++
Explanation / Answer
Code:
#include <iostream>
using namespace std;
// function declaration
float calDisplacement(int t);
int main() {
for(int time=1;time<=20;time++)
cout << "Displacement is : " << calDisplacement(time) << endl;
return 0;
}
// function to calculate displacement of the object
float calDisplacement(int t) {
int v0 = 5;
float a = 3.5;
// formula : d = v0 * t + 1/2 * a * t^2
float d = v0 * t + 0.5 * a * (t*t);
return d;
}
Output:
NOTE: In your screenshot i could see the formula is wrong for calculating displacement. There is a '=' instead of '+'. I corrected it and the formula is d= v0*t + 1/2 * a * t^2
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.