Make a function that would accept a float pointer variable and round off the number to its equivalent whole number. • If the decimal part of the number is greater than or equal to 0.50, round up. • If the decimal part of the number is less than 0.50, round down. · Ex • num = 45.65 : Round up : num = 46.00 • num = 45.48 : Round down : num = 45.00

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section: Chapter Questions
Problem 3PP
icon
Related questions
Question

C language

main.c
Tests
Executions
1 #include<stdio.h
2 void RourndNun (float "ptrl);
3\
4 int main(void) {
No Output
Expected Output
//Hey there, start typing your C code here...
7.
return 8;
Input a float nusber: 45.56
Num: 46.80
10
votd RoundNun (float ptr1)
11-
//function here
12
13)
O Test Case 2
Your Output
No Output
Expected Output
Input a float number: 45.48
Nun: 45.08
Transcribed Image Text:main.c Tests Executions 1 #include<stdio.h 2 void RourndNun (float "ptrl); 3\ 4 int main(void) { No Output Expected Output //Hey there, start typing your C code here... 7. return 8; Input a float nusber: 45.56 Num: 46.80 10 votd RoundNun (float ptr1) 11- //function here 12 13) O Test Case 2 Your Output No Output Expected Output Input a float number: 45.48 Nun: 45.08
1. Round Off
Make a function that would accept a float pointer variable
and round off the number to its equivalent whole number.
• If the decimal part of the number is greater than or equal to
0.50, round up.
• If the decimal part of the number is less than 0.50, round
down.
• Ex
• num = 45.65: Round up : num = 46.00
• num = 45.48 : Round down : num = 45.00
Function:
void RoundNum(float *ptr1);
Make a main program that would ask the user for a float
number. Print the rounded value.
Input
1. float variable
Output
Input a float number: 45.56
Num: 46.00
Transcribed Image Text:1. Round Off Make a function that would accept a float pointer variable and round off the number to its equivalent whole number. • If the decimal part of the number is greater than or equal to 0.50, round up. • If the decimal part of the number is less than 0.50, round down. • Ex • num = 45.65: Round up : num = 46.00 • num = 45.48 : Round down : num = 45.00 Function: void RoundNum(float *ptr1); Make a main program that would ask the user for a float number. Print the rounded value. Input 1. float variable Output Input a float number: 45.56 Num: 46.00
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning