In this program, we are going to share how to split an array from specified position using c programming language. If you are a beginner and want to start learning the c programming, then keep your close attention in this tutorial as I am going to share a c program to split an array from specified position.
Copy the below C program and execute it with the help of C compiler. At the end of this program, We have shared the output of this program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #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]); } } |
Enter the value of n
4
enter the numbers
3
678
345
876
Enter the position of the element to split the array
3
The resultant array is
876
3
678
345
Liked this program? Do Like & share with your friends 🙂
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: c program to split an array from a particular position, c programs, c programs with output, c programs with solutions, divide array into equal parts c, divide array into equal parts in c, how to read an array in c, how to split an array into two arrays in c, list of important c programs