Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Check why the code is not working: if cin >> 1102, when digits[0] == '1' cout >> R1 = 02 #include #include #include using namespace

Check why the code is not working: if cin >> 1102, when digits[0] == '1' cout >> R1 = 02

#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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

20. f(x)

Answered: 1 week ago