Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm new to programming and I don't understand how to finish my C program. How do I make the calculator loop when the user enters

I'm new to programming and I don't understand how to finish my C program. How do I make the calculator loop when the user enters a 1 and quit when the user enters a 0?

image text in transcribed

Also how do I do this function?

Bonus: Take a positive number (N) as an input (perform error check), print the numbers and calculate the sum of all numbers from 0 to N, also sum of all even numbers and sum of all odd numbers from 0 to N. (use for-loop)

Eg: Number is 4

0 1 2 3 4

Sum of all numbers is 10

Sum of even numbers = 6

Sum of odd numbers = 4

- int main(void) int option, units; while(1) displayMenu); printf('Choose a type of connection: ); scanf("%d", &option); if (errorCheck(option)) break; else printf("Invalid Choice! Please enter a valid choice '); while(1) printf("Enter the number of units (In kin):"); scanf("%d", &units); if (errorCheckUnits(units)) break; else printf(" Invalid input! Please enter a positive value '); //Calculations// float totalCharge - (float units + getRate(option, units)/100.0: printf("Total energy charge for the customer is %2f ", totalCharge); float totalBill - totalCharge + charge option): printf("Total Bill due from this connection is: %.21 ", totalBill); //Check for program loop// printf("Do you want to continue and calculate another bill? If yes enter 1, if not enter 0:"); scanf("%d", &option); while (option == 0){ break

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

Advances In Spatial And Temporal Databases 11th International Symposium Sstd 2009 Aalborg Denmark July 8 10 2009 Proceedings Lncs 5644

Authors: Nikos Mamoulis ,Thomas Seidl ,Kristian Torp ,Ira Assent

2009th Edition

3642029817, 978-3642029813

More Books

Students also viewed these Databases questions