Question: Can i get help with this C program requirement. Modify the program Figure 2.13 (letter/while). Create a variable at the top of your code named

Can i get help with this C program requirement.

Modify the program Figure 2.13 (letter/while). Create a variable at the top of your code named power2 and assign it the value 8 Create a variable at the top of your code named result and assign it the value 0 Ask the user to enter FOUR 1's and 0's followed by a '*' In the loop, when the letter is '1' add power2 to result and store it back into result In the loop, change power2 to be the next lower power of 2 After the loop do a cout to print the result and explain it is decimal In other words, the program used to do this: 0101* 0101 Now it should do this 0101* That is 5 in decimal If you run it again: 1010* That is 10 in decimal If you run it again: 0111* That is 7 in decimal In other words, you just wrote a binary to decimal converter. 

Here is my code:

#include #include

int main() { char letter; printf("Please enter FOUR 1's and 0's and add * at the end; "); scanf("%c", &letter); while(letter != '*'){ printf("%c* power2 =", letter); printf(" "); scanf("%c", &letter); }

return (0); }

Thank you

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!