You are on page 1of 3

int main() {

int a, b, c, d, e;

cout << "Input 5 values: ";

cin >> a >> b >> c >> d >> e;

int Input[5] = { a, b, c, d, e };

int n = sizeof(Input) / sizeof(Input[0]);

sort(Input, Input + n);

cout << "Sorted: ";

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

cout << Input[i] << " ";

return 0;

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#include <bits/stdc++.h>

using namespace std;

void BubbleSort(int Check[], int n)

int i, j;

bool swapped;

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

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

if (Check[j] > Check[j + 1]) {

swap(Check[j], Check[j + 1]);

swapped = true;

if (swapped == false)

break;

void PrintArray(int Check[], int size)

int i;

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

cout << " " << Check[i];

int main(){

int a, b, c, d, e, f, g;

cout << "Input 7 value: ";

cin >> a >> b >> c >> d >> e >> f >> g;

int Input[7] = { a, b, c, d, e, f, g };

int N = sizeof(Input) / sizeof(Input[0]);

BubbleSort(Input, N);

cout << "Sorted: ";

PrintArray(Input, N);
return 0;

You might also like