#include<stdio.h>
main()
{
int a[10],x,i,j,n,t;
printf("\n Enter the number of elements=");
scanf("%d",&n);
printf("\n Enter the elements=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n Your elements are=");
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\n Enter the elements that U search=");
scanf("%d",&x);
for(i=0;i<n;i++)
{
if(x==a[i])
{
printf("\n %d is present in %d location",x,i+1);
}
}
}
main()
{
int a[10],x,i,j,n,t;
printf("\n Enter the number of elements=");
scanf("%d",&n);
printf("\n Enter the elements=");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("\n Your elements are=");
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
for(i=0;i<n;i++)
{
printf("\t%d",a[i]);
}
printf("\n Enter the elements that U search=");
scanf("%d",&x);
for(i=0;i<n;i++)
{
if(x==a[i])
{
printf("\n %d is present in %d location",x,i+1);
}
}
}
No comments:
Post a Comment