Menu

Get Help C Program Requirement Modify Program Figure 213 Letter Create Variable Top Code Q43867979

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 8Create a variable at the top of your code named result and assign it the value 0Ask 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 resultIn the loop, change power2 to be the next lower power of 2After the loop do a cout to print the result and explain it is decimalIn other words, the program used to do this:0101*0101Now it should do this 0101*That is 5 in decimalIf you run it again:1010*That is 10 in decimalIf you run it again:0111*That is 7 in decimalIn other words, you just wrote a binary to decimal converter.

Here is my code:

#include <stdio.h>
#include <stdlib.h>

int main() {
  
char letter;
printf(“Please enter FOUR 1’s and 0’s and add * at theend;n”);
scanf(“%c”, &letter);
  
while(letter != ‘*’){
printf(“%c* power2 =”, letter);
printf(“n”);
  
scanf(“%c”, &letter);
}

return (0);
}

Thank you

Expert Answer


Answer to Can i get help with this C program requirement. Modify the program Figure 2.13 (letter/while). Create a variable at the…

OR