Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

AT&T Tasks 1. Rounding to the nearest integer (3 Points). Write a function that can be useful for future programs (like the next problem) which

image text in transcribed
AT&T Tasks 1. Rounding to the nearest integer (3 Points). Write a function that can be useful for future programs (like the next problem) which rounds any POSITIVE floating point value to the nearest integer. The function should "round up: ie. fractional parts of 0.5 and above should round to the next higher whole number. The function has the following prototype: int round to int(float value) / Given: a positive float value * R@turns: the ''alu.e rounded tK The function is given a positive float value and returns an integer which is the rounded value of its arguement. NOTE: you may have noticed that if you restrict the decimal places printed with %f, printf() rounds to the last decimal place printed- this is NOT what we want here. We want an integer value returned by the function that can be used in future calclulations. Other than debug lines (which you should disable when you turn in your files), your function should not return the correct integer value. (Hint: to round positive floats you do NOT need an if statement) You will need a main0 function to test your round to int0 function. This main) is called a "test driver", or just"driver. It's sole purpose is to prompt the user for data, one at a time, give the data to the function, and print the result it gets back to let the user check that the function is operating correctly for different input. Your driver should continue to prompt the user until a 0 is entered, when it should terminate. Call the file containing your code round.c For up to 1 additional bonus point, you can modify your program to work correctly for any float value, 2. Minutes! (5 Points) You have decided to look in to changing your cell phone service because you keep going over the free

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions