1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
miss Akunina [59]
1 year ago
9

use c , c, java or python (any one) programming language for the following programming exercises. do not call built-in library f

unctions that accomplish these tasks automatically. (examples are sprintf and sscanf from the standard c library.) write a function that receives a string containing a 32-bit hexadecimal integer. the function must return the decimal integer value of the hexadecimal integer. demonstrate your function with a driver program.
Computers and Technology
1 answer:
Karo-lina-s [1.5K]1 year ago
3 0

A function that receives a string containing a 32-bit hexadecimal integer. the function must return the decimal integer value of the hexadecimal integer.

<h3>The C++ Program</h3>

#include<iostream>

#include <cstring>

#include <string>

using namespace std;

int getDecimalForm(string);

int main() {

 // string binary;

 // Reads both 0 and B as int 48 while B should be

 string hexadecimal = "01F12EBA";

 int decimalForm;

 int re = hexadecimal[0], te = hexadecimal[1];

 /*cout << "Input an eight digit binary string of 1s and 0s to find the integer

 value in decimal form:\n"; cin >> binary;

 // Input validation

 while (binary.size() != 8 || ((binary[0] != '0' && binary[0] != '1')

 || (binary[1] != '0' && binary[1] != '1') || (binary[2] != '0' && binary[2] !=

 '1')

 || (binary[3] != '0' && binary[3] != '1') || (binary[4] != '0' && binary[4] !=

 '1')

 || (binary[5] != '0' && binary[5] != '1') || (binary[6] != '0' && binary[6] !=

 '1')

 || (binary[7] != '0' && binary[7] != '1')))

 {

 cout << "Input a valid eight digit binary string of only ones and zeros\n";

 cin >> binary;

 }*/

 cout << "The 32-bit binary integer value is " << hexadecimal << endl;

 cout << re << " " << te << " " << hexadecimal[0] - 55 << endl;

 decimalForm = getDecimalForm(hexadecimal);

 cout << endl

      << decimalForm << " is the same integer value expressed in decimal form";

}

// a function in C++ that receives a string containing a 16 - bit binary integer

int getDecimalForm(string hStr) {

 int value, num = 1, total = 0, exponent = 0;

 // Made adding happen starting from the right side

 for (int i = (hStr.size() - 1); i >= 0; i--) {

   if ('0' <= hStr[i] <= '9') {

     cout << hStr[i] << " cat\n";

    if (exponent != 0) {

       for (int j = 0; j < exponent; j++) {

         num *= 16;

       }

     }

     value = num * (hStr[i] - 48);

   }

   if ('A' <= hStr[i] <= 'F') {

     cout << hStr[i] << " dog\n";

     if (exponent != 0) {

       for (int j = 0; j < exponent; j++) {

         num *= 16;

       }

     }

     value = num * (hStr[i] - 55);

   }

   // Keep adding the value of the binary integer

   total += value;

   num = 1;

   exponent++;

 }

 return total;

}


Read more about C++ program here:

brainly.com/question/20339175

#SPJ1

You might be interested in
Customer A with a Bronze service level package calls in a Critical System Failure at 9:00 AM. Customer B with a Silver service l
inysia [295]
This question depends on what the service level packages have to offer as an agreement. Does this question come with a list of what the service levels have to offer?
4 0
3 years ago
What is included on the HP PC Hardware Diagnostics 3-in-1 USB Key that allows you to recover systems that cannot boot?
algol13

Answer:

HP PC Hardware Diagnostics UEFI

Explanation:

The 3-in-1 HP PC Hardware Diagnostics UEFI USB Key helps the client distinguish potential software, hardware, and Operating System issues. Both older and newer HP Desktop and Laptop PCs come with this tool installed. By default, it operates outside the OS to detach equipment issues from other system issues. In the event you do not have it pre-installed, you can get it from the official HP site.

3 0
3 years ago
When defining a system
Sveta_85 [38]

All of the given answer options are necessary to operate the enterprise resource planning (ERP) system when defining a system  landscape.

Enterprise resource planning (ERP) can be defined as a business strategy process through which business firms manage and integrate the main parts of their day-to-day business activities by using software applications.

The main objective and purpose of an enterprise resource planning (ERP) system is to significantly reduce costs by integrating all the operations of a business firm.

In Computer science, when defining a system  landscape, all of the following are necessary to operate the enterprise resource planning (ERP) system:

  • Technical expertise
  • Computer hardware
  • Networking hardware

Read more on ERP system here: brainly.com/question/25752641

7 0
2 years ago
For this exam review lab exercise, you will develop a program that fixes faulty data in a one-dimensional array of integers. Fau
Paladinen [302]

Answer:

start with what you know

Explanation:

3 0
3 years ago
How do i confirm my email address on here
Ipatiy [6.2K]
Hi you go to your email and press confirm and it will come back here to this site and it will auto confirm.
7 0
3 years ago
Read 2 more answers
Other questions:
  • A user is claiming a host can be reached via the IP address but not through the name. What should a technician do first to resol
    13·1 answer
  • Consider the recursive method myprint in this code snippet: public void myprint(int n) { if (n &lt; 10) { system.out.print(n); }
    5·1 answer
  • Write an application named [LastName]_MultiplicationTable and create a method that prompts the user for an integer value, for ex
    11·1 answer
  • .<br> 1. Press the _______ key to move to the next cell in a row.
    14·2 answers
  • What is the fastest way to move data over long distances using the internet, for instance across countries or continents to your
    13·1 answer
  • PHOTOSHOP IS A GRAPHICS EDITING PROGRAM CREATED WITH IMAGES KNOWN AS________ ​
    6·1 answer
  • PLS HURRRYYYYYY!1!1!1!1!1
    5·2 answers
  • How many discussion posts must you complete to meet the Expectations of the replies category
    11·1 answer
  • Which camera is interchangeable<br><br> freeform<br><br> hybrid<br><br> DSLR<br><br> point and shoot
    15·1 answer
  • When can screentips be useful? when finding a tab when looking for a command when pinning the ribbon when using a command.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!