Programming Examples

C program that accept an array of 10 integers and a number to be deleted from the array if found


Write a program that accept an array of 10 integers and a number to be deleted from the array if found. Represent deleted element with -1 and display final array. If not found print appropriate message.

Solution

#include<stdio.h>
int main()
{
	int num[10],a,flag=0,n;
	printf("Enter any 10 Integer Number for Array: ");
	for(a=0;a<10;a++)
	{
		scanf("%d",&num[a]);
	}
	printf("Enter any For Search : ");
	scanf("%d",&n);
	for(a=0;a<10;a++)
	{
		if(n==num[a])
		{
			num[a]=-1;
			flag=1;
		}
	}
	if(flag!=0)
	{
		printf("Array After deletion : ");
		for(a=0;a<10;a++)
		{
			printf("%d\t",num[a]);
		}
	}
	else
	{
		printf("Searched Element not found in Array");
	}
	return 0;
}
Output

Enter any 10 Integer Number for Array:

2

3

4

4

5

4

4

5

6

6

Enter any For Search : 5

Array After deletion : 2        3       4       4       -1      4       4       -1      6       6


Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2025 Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz