Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program that sorts one-dimensional array’s values into descending order using the bubble sort method.

Posted on February 5, 2022February 5, 2022 By myustaadg.com
Spread the love

Write a program that sorts one-dimensional array’s values into descending order using bubble sort method | Array sorting using bubble sort method

So let’s Write Code:

Introduction to C++ Programming | Download and Install Dev C++ Compiler
Install Dev C++

Code:

Write a program that sorts one-dimensional array’s values into descending order using the bubble sort method.

#include"iostream" 
using namespace std;
main()
{
int array[10] = {55,41,12,78,1,69,45,4,36,5};
int u, i, temp;
cout<<"Values of array before sorting\n";
for(i = 0; i<=9; i++)
cout<<array[i]<<" ";
cout<<endl;
// array sorting
u = 9;
while(u>=1)
{
i = 0;
while(i<u)
{
if(array[i] < array[i+1])
{
temp = array[i];
array[i] = array[i+1];
array[i+1] = temp;
}
i++;
}
u--;
}
cout<<"\nValues of array after sorting\n";
for(i = 0; i<=9; i++)
cout<<array[i]<<" ";
}

Hope You will learn Something. Happy Coding.

Visit my YouTube Channel as Well😇 https://www.youtube.com/watch?v=JuIHQ9cLSEw&list=PLbIhkHxfUIItTdcyCb34uRIrPJbXBndIl&index=4

Click on the below Links for more Programming Exercises:

Conditional Structure Exercises: 👉https://myustaadg.com/category/programming-exercises/conditional-structures-exercises/

Array Exercises: 👉https://myustaadg.com/category/programming-exercises/arrays-exercises/

Arrays Exercises, Programming Exercises Tags:array declaration in c++, Array Exercises, Array exercises in C++, array in Object oriented programming, array programming, Arrays, arrays codes, Arrays exercises, Arrays in C++, Arrays in C++ Programming with examples, Arrays in Programming, Arrays with example, c++ arrays declaration and initialization, C++ Arrays with examples, Creating and Using Arrays, how do you initialize an array in c++, Simple arrays code, Write a program that sorts one-dimensional array values into descending order using the bubble sort method., Write a program that sorts one-dimensional array’s values into descending order using the bubble sort method.

Post navigation

Previous Post: Me! Give out of free spoilers
Next Post: Write a program that initializes values in a table and searches for a value from it. If value is found, then it displays the value and its location.

More Related Articles

Write a program that inputs data into a string and searches the ‘vowel’ characters from the string and displays on the screen. Arrays Exercises
Write a program that input user name and displays on the screen in python | Python Programming Programming Exercises
Write a program that inputs data into a table and finds out the maximum and minimum values | Searching Maximum and Minimum values from a table. Arrays Exercises
Simple Data Type Exercises in Python | Python Programming Programming Exercises
Write a program that asks the user for the number of hours worked and the cost per hour. Then show payment on the screen that corresponds to you | Python Programming Programming Exercises
Write a program that inputs the names of students of a class and displays them in ascending and descending order. Arrays Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme