Question: Please help me in creating the following two functions: A function called prnDoubles that prints all elements of a double array, comma-separated with one digit
Please help me in creating the following two functions:
A function called prnDoubles that prints all elements of a double array, comma-separated with one digit after the decimal point.
an another function called eliminate.
This function returns an integer and receives the following:
1- A double array
2- size of the array
3- a double value
4- a double pointer
The function "eliminate", eliminates the values of all the elements of the array that are larger than the received value (argument number 3) by setting them to zero. When done, the eliminate function will set the target of the double-pointer argument to the largest value eliminated and then returns the total number of eliminated doubles.
both functions should work with the following tested program:
int main(void) { int num; double largest; double d[]{ 10.123, 2.234, 5.345, 13.456, 2.567, 11.11 }; num = eliminate(d, 6, 9.5, &largest); prnDoubles(d, 6); printf("%d numbers eliminated and the largest eleminated was %.1lf", num, largest); return 0; }
/*output: 0.0, 2.2, 5.3, 0.0, 2.6, 0.0 3 numbers eliminated and the largest eleminated was 13.5 */
Step by Step Solution
There are 3 Steps involved in it
include stdio h void prnDoublesdouble arr int size for int i 0 i size i printf1lf arri if i size 1 p... View full answer
Get step-by-step solutions from verified subject matter experts
