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
I'm not sure how to do these. By the way, it has to be python.
frutty [35]

Task 1:

float75 = float(75)

string75 = "75"

# you cannot add together a number and a string because a string has no inherent numerical value like a number does.

Task 2:

num = float(input("Enter a number"))

print(num**2)

Task 3:

num = int(input("Enter an integer: "))

print("When you divide "+str(num)+" by 7, the quotient is "+str(num//7)+" and the remainder is "+str(num%7)+".")

Task 4:

gigs = int(input("How many gigabytes does your flashdrive hold? "))

print("A flashdrive with "+str(gigs)+ " gigabyte(s) holds "+str(gigs*8589934592)+" bit(s).")

For task 4, you might have to change the number 8589934592 to something else. I'm not entirely sure how many bits are in a gigabyte. I hope this helps though.

6 0
2 years ago
The requester of sensitive information should not receive access just because of his or her clearance, position, or rank. The re
JulsSmile [24]

Answer:

Need to know

Explanation:

Need to know is a policy or predetermined criterion by which the requester of an information is granted access to the requested information only when a valid need is establish and not just because of his or her clearance, position, or rank.  

7 0
3 years ago
Which statement describes the relationship between science and technology?
Elden [556K]
Answer: science is the study of the world, and technology changes the world to solve problems.
3 0
2 years ago
Read 2 more answers
Quick!!!!!
Vlad [161]

Answer:

B. the current affairs page

Explanation:

it's a simple question

8 0
3 years ago
Read 2 more answers
Identify an advantage of the software as a service (SaaS) approach in public cloud computing. Group of answer choices The user h
adell [148]

Answer:

The user does not need to purchase and install additional hardware to provide increased capacity.

Explanation:

Cloud computing can be defined as a type of computing that requires shared computing resources such as cloud storage (data storage), servers, computer power, and software over the internet rather than local servers and hard drives.

Generally, cloud computing offers individuals and businesses a fast, effective and efficient way of providing services.

Cloud computing comprises of three (3) service models and these are;

1. Platform as a Service (PaaS).

2. Infrastructure as a Service (IaaS).

3. Software as a Service (SaaS).

Software as a Service (SaaS) can be defined as a cloud computing delivery model which involves the process of making licensed softwares available over the internet for end users on a subscription basis through a third-party or by centrally hosting it. Some examples of SaaS are Go-ogle apps, Bigcommerce, Salesforce, Slack, Dropbox, DocuSign, Microsoft Office 365, etc.

An advantage of the software as a service (SaaS) approach in public cloud computing is that the user do not have to purchase and install additional hardware to provide increased capacity because the software provider makes all of the necessary features for smooth operations and proper functioning available to the user.

7 0
2 years ago
Other questions:
  • which student organization helps students with career development by having them become interms to sponsor conferences?
    9·1 answer
  • Cuales Son las características de la máquina analítica de Carlos Babbage ?
    11·1 answer
  • An IT technician has manually configured an IP address on a laptop for a new employee. Each time the employee tries to connect t
    10·1 answer
  • Which option on the Format tab is used to modify particular portions of the chart?
    12·1 answer
  • Match each proofreading mark to the expected result.
    10·1 answer
  • 4.2 lesson practice last one plzs help
    5·2 answers
  • Cuales son las paginas web​
    12·1 answer
  • What should be entered to make the loop print
    6·1 answer
  • The microprogram counter (MPC) contains the address of the next microcode statement for the Mic1 emulator to execute. The MPC va
    12·1 answer
  • 7.2.4 Area of Triangle HELP PLEASE!! (JAVA SCRIPT) I WILL WAIT FOR THE SOLUTION.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!