Question

How would I write the following program in C programming language? Function header: int sumsort(int *a,...

How would I write the following program in C programming language?

Function header: int sumsort(int *a, int *b, int *c)

This function should arrange the 3 values in the memory locations pointed to by a, b, and c in ascending order and also return the sum of the contents of the memory locations a, b, and c.

Homework Answers

Answer #1
#include<stdio.h>
int sumsort(int *a, int *b, int *c){
    if(*a>*b) {
            int temp=*a;
            *a=*b;
            *b=temp;
        }
        if(*b>*c) {
            int temp=*b;
            *b=*c;
            *c=temp;
        }
        if(*a>*b) {
            int temp=*a;
            *a=*b;
            *b=temp;
        }
    return (*a) + (*b) + (*c);
}
int main(){
    int a=10,b=3,c=15;
    int sum=sumsort(&a,&b,&c);
    printf("%d %d %d = %d ",a,b,c,sum);
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
How would I write this function in C programming language? Function header: int input(int *a, int...
How would I write this function in C programming language? Function header: int input(int *a, int *b, int *c) This function should attempt to input 3 integers from the keyboard and store them in the memory locations pointed to by a, b, and c. The input may not be successful in reading all three values. The function should return the number of values that were successfully read.
FOR C PROGRAMMING LANGUAGE Write a recursive C PROGRAMMING LANGUAGE function int sumStrlens(const char* str1, const...
FOR C PROGRAMMING LANGUAGE Write a recursive C PROGRAMMING LANGUAGE function int sumStrlens(const char* str1, const char* str2) which returns the sum of strlen(str1) and strlen(str2). You can assume that strlen(str2) is always strictly greater than strlen(str1) (strlen(str2) > strlen(str1)). You MAY NOT use any function from string.h. You MAY NOT use any square brackets([]) or any type of loops in function.
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i];...
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i]; } return (double)sum/n; } Rewrite the function to eliminate the array subscripting (a[i]), using pointer arithmatic instead. Write a program that reads a line of input and checks if it is a palindrome (ignoring spaces) Write a program that takes the name of a file as a command line argument, and prints the contents of the file (similar to the linux 'cat' program). Write...
Programming in C language (not C++) Write a main function with a function call to a...
Programming in C language (not C++) Write a main function with a function call to a function called Calculation which has two integer arguments/ parameters. The function returns a character. Declare and initialize the necessary data variables and assign balues needed to make it executable and to prevent loss of information. //input 2 integer values //returns the characterequivalent of the higher of the two integer values char Calculation(int, int);
C PROGRAMMING LANGUAGE The following code written in C programming language was run and displays 997705320....
C PROGRAMMING LANGUAGE The following code written in C programming language was run and displays 997705320. Explain why and how this program outputs this number. int main(void) { int a = 5, b =20; int* ptr = &a; int** ptr2 = &ptr; printf("%d\n", ((int)*ptr * (int)*ptr2)); return 0; }
FOR C PROGRAMMING LANGUAGE Consider the following C programming language declaration. Find the values of the...
FOR C PROGRAMMING LANGUAGE Consider the following C programming language declaration. Find the values of the following. If undefined write undefined. int A[2][3] = { {1, 2, 3}, {4, 5, 6} }; A[1][0]: [Value goes here] *A[0]: [Value goes here] *(*A + 1): [Value goes here] **(A + 1): [Value goes here] **(A + 2): [Value goes here]
C programming language. Write a program to print reverse of all the numbers from m to...
C programming language. Write a program to print reverse of all the numbers from m to n using functions with arguments and no return type. The inputs in the program will be m and n variables and need to take these variables as arguments.
Write a program in the C ++ language that executes the following application 1-   Type function...
Write a program in the C ++ language that executes the following application 1-   Type function to find grade (a, b, c, d, e, fnil) 2-. Write a program that requires the user to enter student marks 3- Use the function to show the student's mark with grade
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
In the C programming language, how should I go about writing two programs (sender & reciever)...
In the C programming language, how should I go about writing two programs (sender & reciever) which create a reliable communication protocol to demonstrate reliable unicast using UDP? The sender program runs on one host and reads data files as input, and breaks the contents into UDP datagrams. The receiver should simulate unreliable communication by randomly dropping a percentage of incoming packets. Acknowledgements, retransmission, packet resequencing, and timeouts should all be taken into consideration.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT