Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Utilize pointers Write a program that calls the getNumbers0 function ONLY ONE ti

ID: 3741702 • Letter: U

Question

Utilize pointers Write a program that calls the getNumbers0 function ONLY ONE time. Write a function called getNumbers0 that asks the user for two numbers and returns" the two numbers back to the main function. Then write a function called findLargest0 that will look at the two numbers and figure out which one is larger and return the larger one. Last, write a function called displayLargest(0 that will display the largest number. You may only call each function one time and use only local variables.

Explanation / Answer

The best option would be to store it in an array and then return the pointer

So the code would be

#include <stdio.h>
#include<stdlib.h>
//Compiler version gcc 6.3.0
int* getNumbers()
{
int *arr =(int*)malloc(sizeof(int)*2);
scanf("%d %d",arr,arr+1);
return arr;
}
int findLargest(int *arr)
{
return arr[0]>arr[1]?arr[0]:arr[1];
}
void displayLargest(int *arr )
{
printf("The largest number is %d",findLargest(arr));
}
int main(void)
{
int *arr=getNumbers();
displayLargest(arr);

return 0;
}