Convert the following pseudi code to C++ code. BE sure to define the apprpriat evariables.

a. Store 20 in the speed varaible.
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:

Following are the C++ code

int speed=20; //  Store 20 in the speed varaible.

int time=10; //Store 10 in the time variable.

int distance = speed *time; // multiply by speed *time

cout<<distance; // display the value of distance

Explanation:

Following are the program in C++ language :

#include <iostream> // header file

using namespace std; // namespace

int main()

{

   int speed=20; //  Store 20 in the speed varaible.

int time=10; //Store 10 in the time variable.

int distance = speed *time; // multiply by speed *time

cout<<distance; // display the value of distance

   return 0;

}

Output:20

Explanation:

Following are explanation of following code

  • Declared a vaiable of type int called "speed" and store 20 on it.
  • Declared a vaiable of type int called "time" and store 10 on it.
  • multiply by speed into the time and store into the distance variable.
  • finally print the "display" value