5 1 2 return 0; 1 add(a, b, &sum); printf("The sum of %d and %d is %d\n", a, b, sum); svoid add (int n1, int n2, int *total) { *total = n1 + n2; // *total targets what total points at 3 Something similar happens inside the scanf library function. Function Exercise Write a program named order3.c with a function tripleorder (with void return-type which sorts the values of three integer variables (a, b, and c) into ascending order. The parameters to the function must be three pointers to these three variables. After the function returns the values in the variables should now be sorted from smallest to largest in the order that the variables were passed to the function. This means that the variable of the first pointer will hold the smallest value, and that the variable of the third pointer will hold the largest after the function is called. The main method should ask the user for three numbers, call this function, and print out the three numbers from smallest to largest (on one line with one space between each number) regardless of the order of the numbers entered by the user. To make this precise: If the variables to hold the users three numbers are, in order a, b, and c then use printf("%d %d %d\n", a, b, c); to print out the values in those variables.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

This short program is using basci C instructions

add3.c illustrates pointers as parameters */
int printf(const char *format, ...);
3 void add (int n1, int n2, int *total);
4
5 int main(void) {
6
7
B
9
D
Here is another example:
1
2
int a = 42;
int b = 84;
int sum;
6
= }
add (a, b, &sum);
printf("The sum of %d and %d is %d\n", a, b, sum);
return 0;
1
5 void add (int n, int n2, int *total) {
*total= n1 + n2; // *total targets what total points at
Something similar happens inside the scanf library function.
Function Exercise
Write a program named order3.c with a function tripleorder (with void
return-type which sorts the values of three integer variables (a, b, and c) into
ascending order. The parameters to the function must be three pointers to
these three variables. After the function returns the values in the variables
should now be sorted from smallest to largest in the order that the variables
were passed to the function. This means that the variable of the first pointer
will hold the smallest value, and that the variable of the third pointer will hold
the largest after the function is called. The main method should ask the user
for three numbers, call this function, and print out the three numbers from
smallest to largest (on one line with one space between each number) regardless
of the order of the numbers entered by the user.
To make this precise: If the variables to hold the users three numbers are,
in order a, b, and c then use
printf("%d %d %d\n", a, b, c);
to print out the values in those variables.
Transcribed Image Text:add3.c illustrates pointers as parameters */ int printf(const char *format, ...); 3 void add (int n1, int n2, int *total); 4 5 int main(void) { 6 7 B 9 D Here is another example: 1 2 int a = 42; int b = 84; int sum; 6 = } add (a, b, &sum); printf("The sum of %d and %d is %d\n", a, b, sum); return 0; 1 5 void add (int n, int n2, int *total) { *total= n1 + n2; // *total targets what total points at Something similar happens inside the scanf library function. Function Exercise Write a program named order3.c with a function tripleorder (with void return-type which sorts the values of three integer variables (a, b, and c) into ascending order. The parameters to the function must be three pointers to these three variables. After the function returns the values in the variables should now be sorted from smallest to largest in the order that the variables were passed to the function. This means that the variable of the first pointer will hold the smallest value, and that the variable of the third pointer will hold the largest after the function is called. The main method should ask the user for three numbers, call this function, and print out the three numbers from smallest to largest (on one line with one space between each number) regardless of the order of the numbers entered by the user. To make this precise: If the variables to hold the users three numbers are, in order a, b, and c then use printf("%d %d %d\n", a, b, c); to print out the values in those variables.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY