QBASIC – Calculate distance traveled quickly

Table of Contents

Overview

Below is the QBASIC program to calculate the distance traveled from initial velocity, time, and acceleration.

REM Program to calculate the distance traveled
CLS
INPUT "Enter the initial velocity: "; u
INPUT "Enter the time taken: "; t
INPUT "Enter the acceleration: "; a
S = u * t + (1/2) * a * t ^ 2
PRINT "Distance travelled is: "; S
END

Output

Outputs “Distance travelled is: 130” if initial velocity is 15, time taken is 2 and acceleration is 10

Explanation

Let’s first see the formula: S = u * t + (1/2) * a * t ^2. To convert distance traveled, first, ask the initial velocity (u), time taken (t), and acceleration (a) from the user and add the product of initial velocity (u) and time taken (t) with the product of acceleration (a), time (t) raised to the power of 2 and (1/2).

More Programs

https://thinkshare.one/learn/programming/qbasic/

Leave a Comment

Your email address will not be published. Required fields are marked *

Exit mobile version