बिजनेस मार्केटिंग का लो कॉस्ट फंडा , अपने मोबाइल से ऑटो sms भेजकर मार्केटिंग करे विजिट करे http://autotextsms.com/ बिजनेस मार्केटिंग का लो कॉस्ट फंडा http://autotextsms.com/

Search This Blog

Translate

Showing posts with label Program to delete the specified integer from the array. Show all posts
Showing posts with label Program to delete the specified integer from the array. Show all posts

Program to delete the specified integer from the array

Program to delete the specified integer from the array 


#include <stdio.h>
int main()
{ int vectorx[10]; int i, n, pos, element, found = 0; printf("Enter how many elements\n"); scanf("%d", &n); printf("Enter the elements\n"); for (i = 0; i < n; i++) { scanf("%d", &vectorx[i]); } printf("Input array elements are\n"); for (i = 0; i < n; i++) { printf("%d\n", vectorx[i]); } printf("Enter the element to be deleted\n"); scanf("%d", &element); for (i = 0; i < n; i++) { if (vectorx[i] == element) { found = 1; pos = i; break; } } if (found == 1) { for (i = pos; i < n - 1; i++) { vectorx[i] = vectorx[i + 1]; } printf("The resultant vector is \n"); for (i = 0; i < n - 1; i++) { printf("%d\n", vectorx[i]); } } else printf("Element %d is not found in the vector\n", element); return 0; }


OUTPUT:-
----------------------------------

 Enter how many elements 5 Enter the elements 1 2 3 4 5 Input array elements are 1 2 3 4 5 Enter the element to be deleted 3 The resultant vector is 1 2 4 5
--------------------------------



C Program example List