Hey! For this program
int rounds(float x)
{
return x + (x < 0 ? -0.5 : +0.5); //rounds float to nearest int and //returns int value
}
int main()
{
int size;
float a[5]{ 3.45,7.89,3.32,1.11,4.56 };
}
void print_int(float a[5], int size)
{
}
How does function print_int call from function round to print from the array and makes sure to print the rounded number?
To give you an idea...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
#include <iostream>
int rounds(float);
void print_int(float[], int);
int main()
{
float a[5]{3.45,7.89,3.32,1.11,4.56};
print_int(a,5);
}
void print_int(float a[] , int sz)
{
for (int count = 0; count < sz; count++)
std::cout << rounds(a[count]) << std::endl;
}
int rounds(float x)
{
return x + (x < 0 ? -0.5 : +0.5); //rounds float to nearest int and //returns int value
}
|
Last edited on