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(); }">
Download presentation
Presentation is loading. Please wait.
Published bySheila Walters Modified over 9 years ago
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]); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.