Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a[10], i ,n , newvalue , newindex=-1;
- printf("enter the value of n: ");
- scanf("%d", &n);
- printf( "\nenter %d elements: " ,n);
- for(i=0; i<n; i++)
- {
- scanf("%d",&a[i]);
- }
- printf("\n\nso th elements in the array are: ");
- for(i=0; i<n; i++)
- {
- printf(" %d", a[i]);
- }
- printf ("\n\nenter the value that you search: ");
- scanf("%d",&newvalue);
- for(i=0; i<n; i++)
- {
- if (a[i] == newvalue)
- {
- newvalue=i;
- printf("\n\nfound at index no %d ", i);
- break;
- }
- }
- if (newindex==-1)
- {
- printf ("\nthe value not found");
- }
- else
- {
- for(i=newindex; i<n; i++)
- a[i]=a[i+1];
- }
- printf ("\n\nafter deleting the value: ");
- for(i=0; i<n-1; i++)
- {
- printf(" %d" , a[i]);
- }
- printf("\n\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement