pos;i--) { a[i]=a[i-1]; } a[pos]=item; printf("\nNew Array :- "); for(i=0;i<=n;i++) { printf("%d ",a[i]); } getch(); }"> pos;i--) { a[i]=a[i-1]; } a[pos]=item; printf("\nNew Array :- "); for(i=0;i<=n;i++) { printf("%d ",a[i]); } getch(); }">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rray Programs. Insert and element in the given position of the Array rray.

Similar presentations


Presentation on theme: "Rray Programs. Insert and element in the given position of the Array rray."— Presentation transcript:

1 rray Programs

2 Insert and element in the given position of the Array rray

3 main() { int a[10],i,n,pos,item; clrscr(); printf("enter limit "); scanf("%d",&n); printf("Enter Array : "); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("Given array :- "); for(i=0;i<n;i++) { printf("%d ",a[i]); } printf("Enter item to insert :"); scanf("%d",&item); printf("Enter Position to insert :"); scanf("%d",&pos); for(i=n;i>pos;i--) { a[i]=a[i-1]; } a[pos]=item; printf("\nNew Array :- "); for(i=0;i<=n;i++) { printf("%d ",a[i]); } getch(); }

4 Delete an element from the given position of the Array rray

5 main() { int a[10],i,n,pos; clrscr(); printf("enter limit "); scanf("%d",&n); printf("Enter Array : "); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("Given array :- "); for(i=0;i<n;i++) { printf("%d ",a[i]); } rray printf("Enter Position to delete :"); scanf("%d",&pos); for(i=pos;i<n;i++) { a[i]=a[i+1]; } printf("\nNew Array :- "); for(i=0;i<n-1;i++) { printf("%d ",a[i]); } getch(); }

6 Sort elements in the array rray

7 for(i=0;i<n;i++) { for(j=i+1;j<n;j++) { t=a[i]; a[i]=a[j]; a[j]=t; } printf("\nSorted Array :- "); for(i=0;i<n;i++) { printf("%d ",a[i]); } getch(); } rray main() { int a[10],i,n,j,t; clrscr(); printf("enter limit "); scanf("%d",&n); printf("Enter Array : "); for(i=0;i<n;i++) { scanf("%d",&a[i]); } printf("Given array :- "); for(i=0;i<n;i++) { printf("%d ",a[i]); }


Download ppt "Rray Programs. Insert and element in the given position of the Array rray."

Similar presentations


Ads by Google