Question
Check why the code is not working: if cin >> 1102, when digits[0] == '1' cout >> R1 = 02 #include #include #include using namespace
#include #include #include using namespace std;
int memory[256], reg[16];
void hex_Converter(string str) { // Function to convert into decimal int value, lasttwo; // Defining variables value = 0; int digits[4]; // Defining the array of size 4 for(int i=0;i4;i++)> if((str[i] >= '0') && (str[i] => digits[i] = str[i]-48; value = value * 16 + digits[i]; } else if ((str[i] >= 'A') && (str[i] => digits[i] = str[i]-55; value = value * 16 + digits[i]; } } lasttwo = digits[2] * 16 + digits[3]; // Assigning the last two
for(int i=0;i4;i++)> if (digits[0] == '1') { reg[digits[1]] = lasttwo; cout cout } if (digits[0] == '2') { reg[digits[2]] = reg[digits[3]]; cout cout } if (digits[0] == '3') { reg[digits[1]] = memory[digits[2]+digits[3]]; cout cout } //cout } //cout } string str; int value;
int main() { cout //Taking input string getline(cin, str); hex_Converter(str); // Calling the function }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started