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
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
ADVERTISEMENT