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

Python Susie is learning arithmetic, but she\'s not so good at it yet. When the

ID: 3799637 • Letter: P

Question

Python

Susie is learning arithmetic, but she's not so good at it yet. When the teacher writes down the sum of several numbers together, like 1 +3+2+ 1, Susie has to rearrange the numbers into ascending order before adding them. For example, she would rearrange the previous example to 1 +1+2+ 3 before doing the math. Complete the function math-help (problem) that takes a string representing a math problem and rearranges the digits so that Susie can compute the sum. The function will return the rearranged sum as a string. You may assume that only digits 1, 2 and 3 appear in the argument string problem. You may also assume that at least one symbol appears in problem and that problem is always formatted properly Examples: Function Call Return Value T 1+1+2+37 math help 3+2+1+1') (71+2+37) 21 2132 math help 22 2+2' math help ('2+2') math-help 1+3+2+3+2+1+3+2+3+1+2') '1+1+1+2+2+2+2+3+3+3+3'

Explanation / Answer

#include <stdio.h>

#define MAX 15

void main()

{

    int Math_help[MAX];

    int i,j,n,temp,sum=0;

    printf("Enter the numbers to be added ");

    scanf("%d", &n);

    printf("Enter the elements one by one ");

    for (i = 0; i < n; i++)

    {

        scanf("%d", &Math_help[i]);

    }

    printf("the numbers to be added are ");

    for (i = 0; i < n; i++)

    {

        printf("%d ", Math_help[i]);

    }

    /* sorting given numbers using Bubble sorting */

    for (i = 0; i < n; i++)

    {

        for (j = 0; j < (n - i - 1); j++)

        {

            if (Math_help[j] > Math_help[j + 1])

            {

                temp = Math_help[j];

                Math_help[j] =Math_help[j + 1];

                Math_help[j + 1] = temp;

            }

        }

    }

    printf("Sorted numbers are... ");

    for (i = 0; i < n; i++)

    {   sum=sum+Math_help[i];

        printf("%d ", Math_help[i]);


    }
     printf("sum of the numbers is%d",sum);


}