T Tasks 1 Rounding Nearest Integer 3 Points Write Function Useful Future Programs Like Ne Q26659313

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 justdriver. Its 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 freeAT&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 Show transcribed image text 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

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *