#include
#include
void main()
{
int a[30],n,i,item,loc,count=0;
clrscr();
printf("\nENTER THE NO OF ELEMENTS=");
scanf("%d",&n);
printf("ENTER NO'S=");
for(i=0;i
printf("\n\nENTER ITEM TO BE SEARCHED=");
scanf("%d",&item);
for(i=0;i
if(a[i]==item)
{
loc=i;
printf("\n\n%d IS PRESENT AT LOC %d",item,loc);
count++;
}}
if(count!=0)
printf("\n\nTHE NO IS PRESENT %d TIMES",count);
else
printf("\nTHE NO IS NOT PRESENT");
getch();
}
/*-------------------------------------------------------------------
OUTPUT
----------------------------------------------------------------------
ENTER THE NO OF ELEMENTS=5
ENTER NO'S=1
2
3
1
5
ENTER ITEM TO BE SEARCHED=1
1 IS PRESENT AT LOC 0
1 IS PRESENT AT LOC 3
THE NO IS PRESENT 2 TIMES
*/
u hav take some mistakes in "for" Loop....correct that mistakes.....
ReplyDeletemy dear frnd its nt a mistke....the syntax of for loop is matching wid dat of HTML code...wch is creatng prblm...dnt worry i'll rectify it...
ReplyDeletein dis prgrm ...the for loop is strtng frm i=0 to i is less than "n" then i++...
ReplyDelete