Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Write code for atoi(x) where x is hexadecimal string.

Answer Posted / mohammed sardar

int n=strlen(x) // where x is pointer to hex string
int sum=0;
int leftshift=0;
while(n>0)
{
if((x[n-1]>='0') && (x[n-1]<='9'))
sum+=(x[n-1]-'0')<<leftshift;
if((x[n-1]>='A') && (x[n-1]<='F'))
sum+=(x[n-1]-'A'+10)<<leftshift;
if((x[n-1]>='f') && (x[n-1]<='f'))
sum+=(x[n-1]-'a'+10)<<leftshift;
n--;
leftshift+=4;
}

Is This Answer Correct ?    10 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?

2334


What is const keyword in c?

1122


How do you do dynamic memory allocation in C applications?

1045


WRITE A CODE IN C TO SEARCH A FILE FROM NOTEPAD FILE.

2402


What is difference between structure and union?

1079


Why do we use null pointer?

997


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3841


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

2136


What is the difference between a free-standing and a hosted environment?

1097


What is the size of enum in bytes?

1036


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

1171


Explain what math functions are available for integers? For floating point?

1062


Why we use void main in c?

1099


Explain what does the format %10.2 mean when included in a printf statement?

1290


what do you mean by enumeration constant?

957