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
Katyanochek1 [597]
4 years ago
8

Defining a hexadecimal number as in Problem 67, write the function int hexToDec( const int hexNum[]) to convert a four-digit hex

adecimal number to a nonnegative decimal integer. Do not output the decimal integer in the function. Test your function with interactive input.
Computers and Technology
1 answer:
lyudmila [28]4 years ago
3 0

Answer:

#include <stdio.h>

int hexToDec(const int hexNum[]){

   int result = 0, prod = 1;

   for(int i = 3;i>=0;i-=1){

       result += (prod*hexNum[i]);

       prod = prod * 16;

   }

   return result;

}

int main()

{

   int hexNum[4], i;

   char s[5], ch;

   printf("Enter hexa decimal value: ");

   scanf("%s",s);

   

   for(i = 0;i<4;i++){

       ch = s[i];

       if(ch>='0' && ch<='9'){

         hexNum[i] = ch-'0';

      }

      else if((ch>='a' && ch<='f') || (ch>='A' && ch<='F')){

         if(ch=='A' || ch=='a'){

            hexNum[i] = 10;

         }

         else if(ch=='B' || ch=='b'){

            hexNum[i] = 11;

         }

         else if(ch=='C' || ch=='c'){

            hexNum[i] = 12;

         }

         else if(ch=='D' || ch=='d'){

            hexNum[i] = 13;

         }

         else if(ch=='E' || ch=='e'){

            hexNum[i] = 14;

         }

         else{

            hexNum[i] = 15;

         }

      }

   }

   

   printf("%d",hexToDec(hexNum));

   return 0;

}

Explanation:

You might be interested in
True or false questions. If a statement is false, you must explain the reason why it is false: a). Suppose that TCP is being run
Dima020 [189]

Answer:

a. True

b. False

Explanation:

b. False

At the initial stage, the certificate needs to be encrypted not by the public key of certifier.com but by the by the private key of certifier.com.

After which, the certificate which contains lots information, (i.e there's more information in the certificate than just the public key to be certified). The certificate also the CA’s information, the certificate expiration date, etc.

Only this information’s digital fingerprint is encrypted by the certifier.com’s private key.

8 0
3 years ago
Read 2 more answers
What's one item in your house that represents you
djverab [1.8K]

Answer:

my bed hahaha........

4 0
3 years ago
Read 2 more answers
What is information technology ?​
ella [17]
Information technology can be defined as the study or use of systems for storing, retrieving, and sending information. Can be abbreviated to IT.
7 0
3 years ago
Read 2 more answers
Would you expect all the devices listed in bios setup to also be listed in device manager? would you expect all devices listed i
katen-ka-za [31]
<span>Would you expect all the devices listed in bios setup to also be listed in device manager? = Yes
Would you expect all devices listed in device manager to also be listed in bios setup? = No, the BIOS doesn't know anything about your peripherals etc. that is all managed by the OS.</span>
6 0
3 years ago
Guidelines on how to write a report on how technology has affected office duties
UNO [17]

Answer:

weweweweweewewwewweewewweeew

Explanation:

weweweweewweweweewweewweewewew

5 0
3 years ago
Other questions:
  • Every preprocessing directive must begin with:
    11·1 answer
  • Sizing handles are used in Microsoft® Word® to _____.
    13·1 answer
  • g c 24-hour time (also known in the U.S. as military time) is widely used around the world. Time is expressed as hours since mid
    7·1 answer
  • Consider a Games Expo for Children. Six competitions are laid out for the expo. Tickets are sold according to the age and gender
    11·1 answer
  • Steve is creating a document with proper nouns, which Word continues to identify as being misspelled.
    10·1 answer
  • The statement which assigns value to variable is called a........................statement in c++
    11·1 answer
  • In the U.S. fuel efficiency of cars is specified in miles per gallon (mpg). In Europe it is often expressed in liters per 100 km
    12·1 answer
  • What are programs that are installed without the user knowing
    7·1 answer
  • SOMEONE PLEASE HELP ME OUT WITH!!!!!
    14·2 answers
  • How to write a C++ program that lets the user guess if a randomly generated integer is even or odd then the computer lets them k
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!