Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

Store some elements in an array, accept key & split from that point and add the first half to the end of second half

/* Write a C programme (1-D Array) store some elements in it.Accept key
	& split from that point. Add the first half to the end of second half*/

#include <stdio.h>

void main ()
{
int number[30];
int i,n,a,j;

printf ("Enter the value of n\n");
scanf ("%d",&n);

printf ("enter the numbers\n");
for (i=0; i<n; ++i)
scanf ("%d", &number[i]);

printf ("Enter the position of the element to split the array \n");
scanf ("%d",&a);

for (i=0; i<a; ++i)
{
number[n] = number[0];

for (j=0; j<n; ++j)
{
number[j] = number[j+1];
}
}

printf("The resultant array is\n");
for (i=0; i<n; ++i)
{
printf ("%d\n",number[i]);
}
} /* End of main() */

/*-------------------------------------------------
Output
Enter the value of n
5
enter the numbers
30
10
40
50
60
Enter the position of the element to split the array
2
The resultant array is
40
50
60
30
10
----------------------------------------------------------*/