From cfbaec02ad0a607089037c7c2829c3c8ff1e33b6 Mon Sep 17 00:00:00 2001 From: Chetanya Chopra Date: Mon, 1 Aug 2016 01:04:06 -0700 Subject: [PATCH] Rotate elements of array to right you can rotate elements of array to the right --- Array_right_rotation.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Array_right_rotation.cpp diff --git a/Array_right_rotation.cpp b/Array_right_rotation.cpp new file mode 100644 index 000000000..7e6920fc6 --- /dev/null +++ b/Array_right_rotation.cpp @@ -0,0 +1,31 @@ +#include +using namespace std; +int main(){ + int n,k; + cout<<"Enter size of array=\t"; + cin>>n; + cout<<"Enter Number of indices u want to rotate the array to right=\t"; +cin>>k; +int a[n]; +cout<<"Enter elements of array=\t"; + for(int i=0;i>a[i]; + int temp=0; + for(int i=0;i=0;j--){ + if(j==0){ + a[j]=temp; + } + else{ + a[j]=a[j-1];} + + } + + } + cout<<"Your rotated array is=\t"; + for(int i=0;i