Convert the following pseudocode to C++ code. Be sure to define the appropriate variables.

(a) Store 20 in the speed variable.
(b) Store 10 in the time variable.
(c) Multiply speed by time and store the result in the distance variable.
(d) Display the contents of the distance variable.

Respuesta :

Answer:

// The following program is written in C++ programming language

// Comments are used for explanatory purpose

// Program starts here

#include<iostream>

using namespace std;

int main ()

{

// Declare all Variables

int speed, time, distance;

//a. Store 20 in the speed variable

speed = 20;

// b. Store 10 in the time variable

time = 10;

// c. Multiply speed by time and store the result in the distance variable.

distance = speed * time;

// d. Display the contents of the distance variable.

cout<<distance;

return 0;

}