//(WAP to delete element from array.) #include<stdio.h> #include<conio.h> void main() { char ch='y'; int n,k,a[100],r,i; clrscr(); printf("\nHow many number:"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nElement %d:",i+1); scanf("%d",&a[i]); } for(i=0;i<n;i++) { printf("\n%d",a[i]); } while(ch=='y') { printf("\nEnter number which you want to delete:"); scanf("%d",&r); for(i=0;i<n;i++) { if(a[i]==r) { k=r; } } for(i=k-1;i<=n-1;i++) { a[i]=a[i+1]; } n=n-1; for(i=0;i<n;i++) { printf("\n%d",a[i]); } printf("\nDo you want to continue y or n:"); fflush(stdin); scanf("%c",&ch); } getch(); }
WAP to delete element from array.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment