Friday 10 November 2017

C Program to Split an Array from Specified Position & Add First Part to the End


Code:

#include

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]);
    }
}


Output:

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


More C programs:















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...