Programming in C language to be run on code blocks on Windows (40 Pts) Programmi
ID: 3710492 • Letter: P
Question
Programming in C language to be run on code blocks on Windows
(40 Pts) Programming Problem 1 (20 Pts) Write a call-by-reference function mathify that accepts as parameters three integer pointers (int *a, int *b, int *c) and returns a void. This function should then calculate the sum (addition), product (multiplication), and max of these three values, and replace the value pointed to by a with the sum, the value pointed to by b with the product, and the value pointed to by c with the max. You only need to write the function, not the main in this section a. NOTE: For ALL of the problems below, NO CREDIT WILL BE AwARDED UNLESS EVERY STEP IS SHOWN AND THE FINAL ANSWER IS UNDERLINED (20 Pts) Now that you have written your function mathify, write a main function that will prompt the user to enter in three numbers, then call the function you wrote above on the three numbers entered in. Finally, print out the sum, product, and max results. b.Explanation / Answer
#Program is Easy Here is program PART 1
void mathpy(int *a,int *b,int *c)
{
int sum=a+b+c;
int prod=a*b*c;
int max=a;
if(a>b)max=a;else max=b;
if(max<c)max=c;
*a=sum;
*b=prod;
*c=max;
}
//End of First part
int main()
{
printf("Enter three values... ");
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
mathpy(&a,&b,&c);
printf("Sum=%d Prod=%d Max=%d",a,b,c);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.