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.
/*C PROGRAMMING: HOW TO INSERT ERROR BELOW CODE? QUESTION: This program reads integers from standard input....
/*C PROGRAMMING: HOW TO INSERT ERROR BELOW CODE? QUESTION: This program reads integers from standard input. The first integer indicates the number of values that will follow. Read that many values, and return their sum, ignoring any additional values that may follow. However, if there are fewer integers than specified in the input, print "Error" and terminate. Hint: int n, success; ... success = scanf("%d", &n); // FIRST INTEGER INPUT reads an integer from stdin, returning 1 if the integer...
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
JAVA programming language: What is the output? for (int i = 0; i < 3; i++)...
JAVA programming language: What is the output? for (int i = 0; i < 3; i++) { for (int j = 0; j < 8; j++) { if (j>= 2) { break: } System.out.print("" + i + j + " "); } } Select one: a) 00 11 22 00 11 22 b) 00 01 10 11 20 21 c) 012 123 234 d) 000 001 100 110 200 210
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT