Answer to Question #98320 in C++ for Tamer

Question #98320
Write an algorithm to a program that reads the traveled distance and time of 10 cars, calculate their acceleration, and print the results.
1
Expert's answer
2019-11-11T08:29:59-0500

#include <iostream>

#include <cmath>


using namespace std;


struct car

{

  int traveled_distance;

  float time;

};



int main()

{

  car arr[10];

  int i;

  for(i = 0; i < 10; i++)

  {

    cout << "Enter traveled distance of car " << i+1 << " : ";

    cin >> arr[i].traveled_distance;

    cout << "Enter time of car " << i+1 << " : ";

    cin >> arr[i].time;

  }


  for(i = 0; i < 10; i++)

  {

    cout << 2*arr[i].traveled_distance/(pow(arr[i].time, 2)) << endl;

  }


  return 0;

}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS