Data structer in c using vectors and class would be helpful

Data structer in c++

using vectors and class would be helpful since those are what we are learning.

In this assignment you’re going to build a simple “register machine”, a kind of minimal computer that only supports storing a fixed number of values (i.e., no randomly-accessible “main memory”).

Your machine will consist of an input loop that reads lines of input from the user and then executes them, stopping when the user quits (by executing the stop command). Each line of input consists of a command followed by 1 to 3 arguments. Arguments can be either:

Immediate integer values (positive or negative)

Register names a through d (I.e., this machine only supports four registers)

For some commands, a register name may be required in certain argument positions. Here’s a sample transcript from the official solution implementation (lines starting with > are user input; everything else is output printed by the program):

You may assume that command names and arguments are always separated by at least one space character.

You should bear in mind that we might want to add new commands later on, so think about how to make your program easily extensible in that way (e.g., a huge if-else chain is not very extensible).

Command Description
store x r Store x into register r (a, b, c, or d)
print r Print the value in register r
add x y d Add x and y and store the result in d (x and y may be either, but d must be a register)
sub x y d Subtract y from x and store the result in d
mul x y d Multiply x and y and store the result in d
cmp x y d Compare x and y and store into d
0 if they are equal, -1 if a < b, or 1 if a > b

Solution


#include <iostream>
using namespace std;

int main ()
{
int i;
cout << \"Please enter an integer value: \";
cin >> i;
cout << \"The value you entered is \" << i;
cout << \" and its double is \" << i*2 << \".\ \";
return 0;
}

Data structer in c++ using vectors and class would be helpful since those are what we are learning. In this assignment you’re going to build a simple “register

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site