Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,095 questions

40,777 answers

573 users

How to remove (delete) element from an array in C

1 Answer

0 votes
#include <stdio.h>

#define SIZE 10
  
int main()
{
	int arr[SIZE] = {4, 6, 2, 8, 9, 5, 1, 7};
	int pos = 3;

	for (int i = pos - 1; i < SIZE - 1; i++) {
			arr[i] = arr[i + 1];
	}
        
   
	for (int i = 0; i < SIZE; i++) {
		printf("%d ", arr[i]);
	}

    return 0;
}
  
  
  
/*
run:
  
4 6 8 9 5 1 7 0 0 0
  
*/

 





answered Jul 6, 2020 by avibootz

Related questions

1 answer 98 views
2 answers 88 views
4 answers 136 views
...