Array:
Array is the collection of different values having same data type.
-We have a integer Array that having all integer values.
-Character array is known as String.
Left Shift in Array:
Example-
Array is {1,2,3,4,5}
After Left Shift {2,3,4,5,1}
program-
#include < stdio.h>
int main()
{
int a[6],b[6];
int i;
printf("Enter number in array\n");
//input in array
for(i=0;i< 5;i++){
scanf("%d",&a[i]);
}
//left shift
for(int i=0;i< 5;i++)
{
b[i]=a[(1+i)%5];
}
printf("After left shiftn");
//Now traverse
for(i=0;i< 5;i++)
printf("%d,",b[i]);
}
output-
Enter number in array
1 2 3 4 5
After left shift
2,3,4,5,1,
-In this program, we take a input of 5 numbers in Array.
-then we do the left shift by the b[i]=a[(1+i)%5];
run for every value of i.
-Left shift array is store in another Array then we print that.