Selection sort in C
#include<stdio.h>
int main()
{
int n,i,arr[10],num,found=0;
printf("Enter size of array=\n");
scanf("%d",&n);
printf("Enter array element\n");
for(i=0;i<n;i++)
{
printf("\narr[%d]=",i);
scanf("%d",&arr[i]);
}
printf("which no want to find\n");
scanf("%d",&num);
for(i=0;i<n;i++)
{
if(arr[i]==num)
{
found=1;
printf("Enter element is found in the array");
break;
}
}
if(found==0)
printf("Enter element is not found");
}
output(element not found)
Enter size of array=
5
Enter array element
arr[0]=3
arr[1]=5
arr[2]=4
arr[3]=7
arr[4]=3
which no want to find
8
Enter element is not found
output:(entered element found)
Enter size of array=
5
Enter array element
arr[0]=5
arr[1]=6
arr[2]=7
arr[3]=3
arr[4]=4
which no want to find
4
Entered element is found in the array
Comments
Post a Comment