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
_________ is critical to Amazon's success.<br><br> SCM<br><br> JIT<br><br> ERP<br><br> VMI
Minchanka [31]

Answer: SCM

Explanation:

 SCM stand for supply chain management system and it is amazon's competitive strategy. The amazon SCM is the strategic of being the retailer according to the customer's choice.

Inventory system for multi-tier is the major component for the amazon's SCM. The main key aspect for the amazon supply chain management is that  it is responsible for development in the trade market over years.The amazon SCM are basically responsible for analysis all the major growth and productivity ij the market by using the supply chain management process.

8 0
3 years ago
In chapter 11, we finally learn how the book got its title. What is the sign of the beaver? Is that what you expected when you r
Ostrovityanka [42]

Answer:

:D

Explanation:

Literally speaking, the sign of the beaver is a scratched pattern the Beaver clan uses to mark their territory. Symbolically, though, it lets other clans know not to hunt on the land it marks.

Authors help readers understand their characters in two different ways: direct characterization and indirect characterization. When an author uses words and phrases that describe a character, it's called direct characterization.

Some books use this technique more than others. Although direct characterization can be interesting if done well, most authors prefer to present their characters using indirect characterization—that is, by showing the reader what characters are like by how they act, what they think, and what other people say about them.

3 0
3 years ago
What is the best programing language to use for building video games?
Alexxandr [17]

hey

I'm going to college for game design.

one of the best languages and the one I'm studying in is c# it is used in unity and many other game engines but there are many more. Just to list a few c++, Java, and many more it is up to you. if you would like more info about this just let me know By the way what game are you planning to make that is one of the most important factors

Hope this helps

-scav

6 0
3 years ago
4.2.5 codehs text messages answer
N76 [4]

Answer:

public class TextMessage

{

   private String message;

   private String sender;

   private String receiver;

   

   public TextMessage(String from, String to, String theMessage)

   {

       sender = from;

       receiver = to;

       message = theMessage;

   }

   

   public String toString()

   {

       return sender + " texted " + receiver + ": " + message;

   }

}

4 0
2 years ago
A ________ -tier design includes a middle layer between the client and server that processes the client requests and translates
Vanyuwa [196]

Answer:

Three.

Explanation:

5 0
3 years ago
Other questions:
  • Assume the following variable definitions int a = 5, b = 12; double x = 3.4, z = 9.1. What are the values of the following expre
    7·1 answer
  • You are adding new wires in your building for some new offices. The building has a false ceiling that holds the lights and provi
    8·1 answer
  • Text messaging is an example of nonverbal communication. Please select the best answer from the choices provided. T F
    7·2 answers
  • A law office has been leasing dark fiber from a local telecommunications company to connect a remote office to company headquart
    14·1 answer
  • B) If you send me an email, then I will finish my program. If you do not send me an email, then I will go to sleep early. Theref
    10·1 answer
  • Which ORDER BY clause causes 10 rows to be retrieved from the result set, starting with the 20th row?
    5·1 answer
  • Which of the following statements about the relationship between hardware and software is true? a) Hardware can be present in in
    9·1 answer
  • How do I create a simple percentage function to gather a score for a quiz in PHP?
    14·1 answer
  • The =COUNT function calculates what value?
    15·2 answers
  • What is a port?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!