Rabu, 04 Agustus 2010

tugas searching and sorting

#include
#include
#include
void main(){
int arr[100],i,element,no;
clrscr();
printf("\nEnter the no of Elements: ");
scanf("%d", &no);
for(i=0;i printf("\n Enter Element %d: ", i+1);
scanf("%d",&arr[i]);
}
printf("\nEnter the element to be searched: ");
scanf("%d", &element);
for(i=0;iif(arr[i] == element){
printf("\nElement found at position %d",i+1);
getch();
exit(1);
}
}
printf("\nElement not found");
getch();
}

Output:

Enter the no of Elements: 5

Enter Element 1: 12

Enter Element 2: 23

Enter Element 3: 52

Enter Element 4: 23

Enter Element 5: 10

Enter the element to be searched: 23

Element found at position 2