From bed7db9127ae8e4b01e260fde9cd554dea4a92e6 Mon Sep 17 00:00:00 2001 From: ankurgupta255 <43845288+ankurgupta255@users.noreply.github.com> Date: Sun, 28 Oct 2018 12:36:14 +0530 Subject: [PATCH] Move Zeroes This is the code in C++ to "Move The Zeroes Of An Array to the End". --- Algorithms/Array/Move Zeroes to The End.cpp | 38 +++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Algorithms/Array/Move Zeroes to The End.cpp diff --git a/Algorithms/Array/Move Zeroes to The End.cpp b/Algorithms/Array/Move Zeroes to The End.cpp new file mode 100644 index 000000000..79b1d9897 --- /dev/null +++ b/Algorithms/Array/Move Zeroes to The End.cpp @@ -0,0 +1,38 @@ +#include +using namespace std; +int main() +{ + int n; + int a[100]; + int i=0; + int j=n-1; + int cnt=0; + cout<<"Enter the size of the array: "; + cin>>n; + cout<<"Enter the array Elements: "; + for(int i=0;i>a[i]; + } + for(i=0;i=0;j--){ + if(a[j]!=0){ + int temp=a[i]; + a[i]=a[j]; + a[j]=temp; + break; + } + else{ + cout<<"All Elements are 0s."; + }}}} + for(i=0;i