Question: In C Writ a function that will convert a binary numbr as a string to an unsigned integer valu. This is a task that requirs
In C
Writ a function that will convert a binary numbr as a string to an unsigned integer valu. This is a task that requirs only about 8 lines of cod.
The function you will fill in will b this:

For xample, if you do this, the output should b 327.

/** * Convert a binary representation of a * number to an unsigned integer. * * * * For this function, the values Y and N represent * true (1) and false (6) respectfully. So, the string: * YYNY is equal to 1101 binary, which is equal to 13. * Unexpected characters are ignored. Only Y's and N's are * considered to be valid. Stop converting when you get * to a space character or the end of the string. The * representation is case-sensitive (only Y/N are valid * true and false values). * * 'aYNCY YY' should convert to 5 * 'NYNYny' should convert to 5 * * @param binary Binary number as a string of 'Y's and 'N's * and other characters. * @returns unsigned int result */ unsigned int bin2dec(const char *binary) { } printf("%u ", bin2dec("YNYNNNYYY"))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
