Sign InCreate Account

Upgrade to Pro

Upgrade Now

Coding Workspace

EditorProjectsPractice QuestionsTimed Mock ExamsFlowcharts

PseudoEditor AI

Pseudocode TutorCode GeneratorCode FixerCode Converter
Back to Problems
PreviousNext

Sign in to run tests against edge cases and save your code automatically.

Problem Description

Medium

Bubble Sort with Swap Count

PROSorting & Searching
Bubble Sort
1D & 2D Arrays

Write a program that inputs 5 integers into an array and sorts them into **ascending** order using a bubble sort. Swap two neighbouring values only when the left one is **strictly greater** than the right one. Output the 5 sorted values, one per line, followed by a final line showing the total number of swaps made during the sort. For example, the input 5 1 4 2 8 outputs 1, 2, 4, 5, 8 (one per line) and then 4.

Example Input

5 1 4 2 8

Example Output

1 2 4 5 8 4

Success Rate:

0% (0 passed / 0 attempted)

Code

Draft auto-saved

Test Results

Click "Test Code" to evaluate your code against the tests.

Product

For SchoolsOverviewFeaturesFAQ
PseudoEditor

© 2026 PseudoEditor. All rights reserved.