In computer science, pseudocode is a plain language description of the steps in an algorithm or another system. Pseudocode often uses structural conventions of a normal programming language, but is intended for human reading rather than machine reading. It typically omits details that are essential for machine understanding of the algorithm, such as variable declarations and language-specific code. The programming language is augmented with natural language description details, where convenient, or with compact mathematical notation. The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code, and that it is an efficient and environment-independent description of the key principles of an algorithm. It is commonly used in textbooks and scientific publications to document algorithms and in planning of software and other algorithms.
priceOfTrip = milesTraveled / mpg * costOfGas
#include < iostream> using namespace std; int main() { float milesTraveled{0}, mpg{0}, priceOfTrip{0}, costOfGas{0}; cout << "Enter the miles traveled: "; cin >> milesTraveled; cout << "Enter the miles per gallon for your car: "; cin >> mpg; cout << "Enter the costOfGas per gallon for gas: "; cin >> costOfGas; priceOfTrip = milesTraveled / mpg * costOfGas; cout << "The cost of your trip will be $" << priceOfTrip << endl; return 0; }
prompt the user for miles traveled get milesTraveled prompt the user for mpg get mpg prompt the user for costOfGas get costOfGas priceOfTrip = milesTraveled / mpg * costOfGas print "the price of the trip is $" priceOfTrip
input: get miles: 100 get mpg: 25 get cost of gas: 3 Output: The trip will cost $12.00 Work Area: milesTraveled mpg costOfGas priceOfTrip ------------- --- --------- ----------- 100 25 3 12 100/25 = 4 4 * 3 = 12