// n - no.of elements in array // i - for traversing the array // j - location of the element to be deleted // a - Array #include<stdio.h> #include<conio.h> void main() { int a[30],n,i,j; printf("n Enter no of elements :"); scanf("%d",&n); /* read n elements in an array */ printf("n Enter %d elements :",n); for(i=0;i 〈 n;i++) scanf("%d",&a[i]); /* read the location of the element to be deleted */ printf("n location of the element to be deleted :"); scanf("%d",&j); /* loop for the deletion */ while(j 〈 n) { a[j-1]=a[j]; j++; } n--; /* no of elements reduced by 1 */ /* loop for printing */ for(i=0;i 〈 n;i++) printf("n %d",a[i]); getch(); }
About Me
- Amit Singh Thakur
- Raipur, Chhattisgarh, India
- Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.
Monday, September 2, 2013
C Program to Delete an element from the specified location from Array
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment