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

programming in C language NOTE For ALl ofthe problems below, No CREDIT WILL L BE

ID: 3715516 • Letter: P

Question

programming in C language

NOTE For ALl ofthe problems below, No CREDIT WILL L BE AWARDED UNLESS EVERY STEE Is SHOWN AND THE s. (40 Pts) Programming Problem 1 a. (20 Pts) Write a call-by-reference function reorder that accepts as parameters two integer pointers (int *a, int b) and returns a void. This function should then reorder them in ascending order, so that the value pointed to by a will store the largest value and b will store the smallest value. You only need to write the function, not this section. the main in luow that you haue written your funct t? reorder Us cte LU e ater

Explanation / Answer

#include <stdio.h>


void reorder(int*, int*);

int main()
{
int a, b;

printf("Enter the value of a and b ");
scanf("%d%d",&a,&b);

printf("Before reordering a = %d b = %d ", a, b);

reorder(&a, &b);

printf("After reordering a = %d b = %d ", a, b);



return 0;
}

void reorder(int *a, int *b)
{
  
int temp;
if(*a < *b) //a stores the largest value and b stores the smallest value
{
temp = *b;
*b = *a;
*a = temp;
}
  
}