Answers for "delete a number in array in c"

C
2

how to delete element from array c

for (int i =  pos; i < size; i++)
{
    arr[i-1]= arr[i];
        
}
Posted by: Guest on May-25-2021
3

c remove element from array

void remove_element(array_type *array, int index, int array_length)
{
   int i;
   for(i = index; i < array_length - 1; i++) array[i] = array[i + 1];
}
Posted by: Guest on February-19-2021
0

delete a number in array in c

#include<stdio.h>

void main()
{
    int a[10], del_num, i, n, pos;


    printf("Enter number of elements in array: ");
    scanf("%d", &n);

    for(i = 0; i < n; i++)
    {
        printf("Enter %d number: ",i+1);
        scanf("%d", &a[i]);
    }

    printf("\n\nThe input array is: ");

    for(i = 0; i < n; i++)
    {
         printf("%d ", a[i]);
    }


    printf("\n\nEnter the number to be deleted: ");
    scanf("%d", &del_num);


    for(i = 0; i < n; i++)
    {
        if(a[i] == del_num)
        {
            a[i]=0;

        }
    }

    printf("\n\nResultant array is: ");

    for(i = 0; i < n; i++)
    {
        printf("%d  ",a[i]);
    }
}
Posted by: Guest on June-24-2021

Code answers related to "C"

Browse Popular Code Answers by Language