



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
How can we trevers the array's element and how can we insert or delete the the elements in array. We can insert or delete the elements in array at first, middle or last position (means every position) .
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!
Name :- Manish Panwar CS - AI 3rd semester Poornima University Jaipur /* Program to insertion , deletion , traversing of an array */ #include<stdio.h> int main() { int a[50],size,i,choice,pos,n; printf("Enter size of array : "); scanf("%d",&size); printf("Enter element of array \n"); for(i=0;i<size;i++) { scanf("%d",&a[i]); }
printf("press 1 for insert a value of an array \n"); printf("press 2 for delete a value of an array \n"); printf("press 3 for traversing of an array \n"); printf("\nEnter your choice : "); scanf("%d",&choice); switch(choice) { case 1: printf("your aray is : \n"); for(i=0;i<size;i++) { printf("%d ",a[i]); } printf("\n\nEnter position that you want to insert element : "); scanf("%d",&pos); printf("Enter value that you want to insert : "); scanf("%d",&n); for(i=size;i>=pos;i--)
scanf("%d",&pos); for(i=(pos-1);i<size-1;i++) { a[i]=a[i+1]; } size--; printf("\nYour new array: \n"); for(i=0;i<size;i++) { printf("%d ",a[i]); } break; case 3: printf("\nTraversing of Array : \n\n"); for(i=0;i<size;i++) { printf("%d ",a[i]); }
break; } return 0; }