I am not grasping C++ very well and I am having a hard time with this assignment:

• Write a program that does the following: Calculates the Velocity and Momentum of an object. The formula for the velocity is V=d/t and the formula Momentum is m=mass*velocity. Your program should consist of four functions: Passing By Values (one), two Passing By References (functions), and Passing By Pointers (one). It should also have a for loop and necessary print statements to print the result.
• The Passing By Values function is to calculate the velocity of the object, where you pass two parameters to this function a constant distance, but the time is the value of the for loop: I=1.
• The Pass By Pointers function calculates the momentum of the object, where you pass two parameters to this function: The Velocity and a constant mass of an object: mass=205.
• The first Pass By References function. This function “Pass by references” calculates the total of Velocity. For example, it keeps tract of cumulative velocity. In this case the function receives two parameters velocity and initialVelocityTotal=0 and the function keeps tract of the total velocity.
• The second Pass By Reference function uses the same method as the other Pass by Reference function, but you replace the Velocity parameters with Momentum: initialMomentumTotal=0.

Please show your code, and explain what the issues are before expecting any help here. We're not here to do your homework for you.

I am still working on it. I will post more when I get more done. I have changed what I had on the assignment since I made the original post. Thank you.

#include <iostream>
#include <cmath>

using std::cout;
using std::cin;
using namespace std;
using std::endl;

double velocity (double, double);

void passbyvalue (double, double);
void passbyref (double, double);

int main () {
    double distance=0, time=0, velocity=0;
    char quit = ' ';
    while (quit != 'y') {
    int distance;
    int time;
    int velocity;
    int result;



    cout << "Please enter distance: ";
    cin >> distance;

    cout << "Please enter time: ";
        cin >> time;;

        cout << distance endl;
        cout << time endl;
        cout << velocity endl;

        passbyvalue (distance, time);
        cout << distance endl;
        cout << time endl;
        cout << velocity endl;

        passbyref (distance, time);
        cout << distance endl;
        cout << time endl;
        cout << velocity endl;

    velocitySet= velocity (distance, time);

    cout << "Do you want to quit? ";
    cin >> quit;



}

    return 0;

    }

    double velocitySet (double d, double t) {

        double v=d/t;
        return velocitySet;

    }

    void passbyvalue (double, double) {

    }

    void passbyref (double &firstD, double &firstT) {
        firstD;
        firstT;
This article has been dead for over six months. Start a new discussion instead.