Solved programming problem

Left Shift 1D array in C.

Source code

#include<stdio.h>

int main()

{

    int array[50],i,a,c=0,n,s,m;

    int swap;

    printf("Please enter the number of element you want to use in the array:");

    scanf("%d",&n);

    printf("
PLease enter %d elements of the array:
",n);

    for(i=0; i<n; i++)

    {

        scanf("%d",&array[i]);

    }

    printf("Pleas Enter how much you want to shift the array in left side:");

    scanf("%d",&s);

    for(i=0; i<n; i++)

    {

        if(i+s<n)

        {

            array[i]=array[i+s];

        }

        else

        {

           array[i]=0;

        }

    }

    printf("After Shifting Array by %d left position: 
",s);

    for(i=0;i<n;i++)

    {

        printf("%d ",array[i]);

    }

    return 0;

}

Output

Please enter the number of element you want to use in the array: 5

PLease enter 5 elements of the array: 1 2 3  4 5

Pleas Enter how much you want to shift the array in left side: 2

After Shifting Array by %d left position: 3 4 5 0 0

Join the discussion

Add your comment

3 previous comments

lautlew

So, we used genetic pharmacotherapy to ask whether adult induction of GLS1 heterozygosity would attenuate amphetamine responsiveness <a href=https://cialis.lat/discover-the-best-prices-for-cialis>tadalista vs cialis</a>

arbinny

<a href=https://buylasixon.com/>lasix administration</a> Here is an example of a post cycle therapy for advanced steroid users

Fafabodia

Lspqqc Site Confiance Achat Cialis [url=https://bestadalafil.com/]cialis 20 mg[/url] Iszmnz <a href="https://bestadalafil.com/">Cialis</a> is levitra safe Binwlg https://bestadalafil.com/ - Cialis how long does cialis work Zoqpzw