Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, i am having some trouble fixing my mistakes. If anyone can help me fix them. I am suppose to do hex to decimal conversations

Hello, i am having some trouble fixing my mistakes. If anyone can help me fix them. I am suppose to do hex to decimal conversations in c and i have done that with my program. The problem i am having is, I have to put the hex values in an array and also put the decinal outcomes in a seperate array and use the program to convert those hex values to decimal and compare those decimal values. i have written the program, but i am having issues with where it is going wrong. here is my program. The issues are like, forbids comparison between pointer and integer and few more. Someone take a look and help me debug

#include

#include "catch.hpp"

#include

//int main()

int f(int x) {return x;}

TEST_CASE("listing 3.2")

{

int x;

unsigned int y;

char aChar[8][16]= {"a000", "ffff", " 0400", "1111", "8888", "0190", "abcd", "5555"};

int xs[8]={0}; // inputs

int ys[8] = {40960, 65535, 1024, 4369, 34952, 400, 43981, 21845};

//int j=1;

x = 0; // initialize result

while (aChar != ' ') // look for return key

{

//j++;

x = x << 4; // make room for next four bits

if (aChar <= '9')

{

x = x + (int)(aChar & 0x0f);

}

else

{

aChar = aChar & 0x0f;

aChar = aChar + 9;

x = x + (int)aChar;

}

}

for (int i= 0; i < 8; i++)

{

sscanf(a[i], "%i", &xs[i]);

CHECK(xs[i] == ys[i]);

}

printf ("end of the program. ");

}

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

Database Systems Design Implementation And Management

Authors: Peter Robb,Carlos Coronel

5th Edition

061906269X, 9780619062699

More Books

Students also viewed these Databases questions

Question

calculating coefficent of lift program ucr cs 0 1 0 b

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago