Question

Write a C program that will sort the list of the numbers into ascending output using...

Write a C program that will sort the list of the numbers into ascending output using pointers.

(10,20,30,0,3,4,5,6,7,8,9,100,200,300,55,65,35,24,19,20)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h>

int main() {
    int arr[] = {10, 20, 30, 0, 3, 4, 5, 6, 7, 8, 9, 100, 200, 300, 55, 65, 35, 24, 19, 20};
    int size = sizeof(arr) / sizeof(int);
    int i, j, temp;

    for (i = 0; i < size; ++i) {
        for (j = 0; j < (size - (i + 1)); ++j) {
            if (*(arr + j) > *(arr + j + 1)) {
                temp = *(arr + j + 1);
                *(arr + j + 1) = *(arr + j);
                *(arr + j) = temp;
            }
        }
    }

    for (i = 0; i < size; ++i)
        printf("%d ", *(arr + i));
    printf("\n");

    return 0;
}

0 3 4 5 6 7 8 9 10 19 20 20 24 30 35 55 65 100 200 300 Process finished with exit code

Add a comment
Know the answer?
Add Answer to:
Write a C program that will sort the list of the numbers into ascending output using...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C programing Write a program to sort numbers in either descending or ascending order. The program...

    C programing Write a program to sort numbers in either descending or ascending order. The program should ask the user to enter positive integer numbers one at a time(hiting the enter key after each one) The last number entered by the user should be -1, to indicate no further numbers will be entered. Store the numbers in an array, and then ask the user how to sort the numbers (either descending or ascending). Call a function void sortnumbers ( int...

  • C programming Strictly - Write a program to sort an array of integers via arrays of...

    C programming Strictly - Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. Problem 1 (68 points): Write a program to sort an array of integers via arrays of pointers to those integers as shown in the figure. The code should contain the following functions: 1)to randomly generate an array of integer numbers; 2) to allocate memory and build the arrays of pointers as shown in the figure...

  • Write a java program to sort arrays using 3 different methods: Bubble Sort, Selection Sort and...

    Write a java program to sort arrays using 3 different methods: Bubble Sort, Selection Sort and Insertion Sort. The numbers to be sorted will be obtained using a library function which generates pseudo-random numbers. TO Do 1. Fill an array with 140 real numbers between 0.00 and 945.00. Generate the numbers using the subroutine that generates random numbers. Make a spare copy of the array; you will need it later. 2. Call a subroutine to print the contents of the...

  • Write a c++ program that sorts one – dimensional array’s value into ascending order using the...

    Write a c++ program that sorts one – dimensional array’s value into ascending order using the selection sort method

  • Write a C program to add and subtract any two given integer numbers using pointers

    1- Write a C program to add and subtract any two given integer numbers using pointers.  2- Write a C program to find the factorial using a function and pointers.  3- Write a C program to find the square of an Integer number using a function and pointers.  4- Write a C program to find the area and perimeter of a rectangle using a function and pointers.  5- Write a C program to find the larger of two integers numbers using...

  • Write a python program to sort numbers in descending order using insertion sort? Enter numbers: 1...

    Write a python program to sort numbers in descending order using insertion sort? Enter numbers: 1 2 3 4 4 3 2 1

  • Write a program that takes a list of integer numbers from a user and creates a...

    Write a program that takes a list of integer numbers from a user and creates a new sorted in ascending order list. As output you need to print original list and sorted one. use list and while python

  • c++ no pointers just follow instructions Write a program (array.cpp) that read positive floating point numbers...

    c++ no pointers just follow instructions Write a program (array.cpp) that read positive floating point numbers into an array of capacity 100. The program will then ask for one of three letters(A, M or S). if the user inputs something other than one of these letters, then the program should ask for that input until an A, M, or S is entered. A do-while loop should be used for this. If the user inputs an A, then the program should...

  • Consider the following python code that will sort the list of numbers using the Bubble Sort...

    Consider the following python code that will sort the list of numbers using the Bubble Sort algorithm def bubbleSort(alist): print(alist) for j in range (len(alist) - 1, 8, -1): for i in range(): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp print(alist) alist = [52, 25, 94, 17, 25, 52] bubbleSort (alist) print(alist) Sort the following series of values into ascending order using the Bubble Sort algorithm. Write out the complete row of...

  • Using c++ Write a program that reads in a list of up to 25 first names...

    Using c++ Write a program that reads in a list of up to 25 first names from an input file nameData.txt and allows the user to display the name data, sort it in ascending or descending order, count the number of occurrences of a given name, or exit the program. The input file consists of a single names per line with each line terminated with an end of line (i.e. using Enter key to end the line). Your program should...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT