Friday, 1 March 2013

Program to find minimum element of Array


By on 05:00

Q)Write a program to create array and find the minimum or smallest element of array with its location?

Note:-You can also create this program in c++(c plus plus),java,c#(c sharp) etc. with the same logic.


P:void main()
{
int arr[30],i,limit,min,l;
printf("Enter limit");
scanf("%d"&l);
l=0;
printf("Enter Array");
for(i=0;i<limit;i++)
scanf("%d",&arr[i]);
min=arr[0];
l=0;
for(i=0;i<limit;i++)
{
if(arr[i]<min)
{
min=a[i];
l=i;
}
}
printf("%d",l=%d,min,l);
getch();
}


If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...