Q : 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.
Answer :
#include<stdio.h>
#include<conio.h>
/*============================
Girfa Student Help
Delete operation in array
==============================*/
void main()
{
int ar[10],i,n;
clrscr();
for(i=0;i<10;i++)
{
printf("Enter
number for %d position>> ",i+1);
scanf("%d",&ar[i]);
}
printf("Enter
number for search>> ");
scanf("%d",&n);
for(i=0;i<10;i++)
{
if(ar[i]==n)
break;
}
if(i==10)
printf("Search
No. for found");
else
{
ar[i]=-1;
/*
printing array */
for(i=0;i<10;i++)
printf("\t%d",ar[i]);
}
getch();
}
nice work, I am getting most of the answers to my questions of O level
ReplyDelete