Loops help

V_y = V_y - ( 9.81 * t ); ycord = ycord + V_y * t; These two equations need to be run 100 times and I need to output the 100th answer. Do i need to use loops or can I use some math to figure it out? Angle and V_0 are user input.

#include <iostream>
#include <math.h>
using namespace std;
double t = .2
double V_1;
double angle;
double V_2;
double V_3;
double y

int main ( )
{

V_y = V_0 * sin (angle)

// Y

ycord = t * V_y ;


V_y = V_y - ( 9.81 * t );
ycord = ycord + V_y * t;


q;
Last edited on
In this case, use math for sure as it can give the best performance.
application of mathematics instead of loop makes very fast calculation with no extra overhead to your system with same accurate result....also your problem can be done easily using mathematics. So use mathematics instead of unnecessary looping. Looping is done where result is obtained by iterative method, where direct mathematical formula is not applicable ex: most of the problems in Numerical Method.
Last edited on
Topic archived. No new replies allowed.