Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

1461368332, 978-1461368335

More Books

Students also viewed these Databases questions

Question

Define capital structure.

Answered: 1 week ago

Question

List out some inventory management techniques.

Answered: 1 week ago

Question

Discuss consumer-driven health plans.

Answered: 1 week ago