This is my first task using pointers…
I’m need to create a function that finds out which of two numbers is bigger, and than replace both of them to have the bigger value and print them.
I’m getting an error in the prinf of the main() :
argument type ‘void’ is incomplete
My code is:
#include <stdio.h>
void larger_of(double * x, double * y);
int main()
{
double num1 = 4.5;
double num2 = 5.5;
printf("the original two numbers is %.1lf and %.1lf\n", num1, num2);
printf("now: %lf and %lf", larger_of(&num1, &num2));
}
void larger_of(double * x, double * y)
{
if (* x > * y)
* y = * x;
else if
(* x < * y)
* x = * y;
else
printf("they are equale!!");
}
larger_ofis a function that returns nothing. You cannot print its return value.To print your numbers after a call to
larger_ofjust do: