From 79dd0cdf00fd2cabc43f9efb42773992ed05e3f7 Mon Sep 17 00:00:00 2001 From: GeshnaSikarwar <79712752+GeshnaSikarwar@users.noreply.github.com> Date: Mon, 31 Oct 2022 17:47:19 +0530 Subject: [PATCH] sorting array --- sorting technique/sorting.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 sorting technique/sorting.cpp diff --git a/sorting technique/sorting.cpp b/sorting technique/sorting.cpp new file mode 100644 index 0000000..c83c8e7 --- /dev/null +++ b/sorting technique/sorting.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int a[5]={4,2,6,1,0}; + int temp; + for(int i=0;i<5;i++) + { + for(int j=i+1;j<5;j++) + { + if(a[i]>a[j]) + { + temp=a[i]; + a[i]=a[j]; + a[j]=temp; + } + } + } + for(int i=0;i<5;i++) + { + cout<