use selection sort its easy
#include<stdio.h>
void main()
{
int ,i,j,temp,a[100],pos ;
printf(“Enter the number of item “);
scanf(”%d”,&n);
\input element to sort
printf(“enter the items to sort \n”);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
\sort the elements
for(i=0;i<n-1;i++)
{
pos =i;
for(j=i+1;j<n;j++)
{
if(a[j]<a[pos])pos=j;
}
temp=a[pos];
a[pos]=a[i];
a[i]=temp;
}
printf(“the sorted items are \n”);
for(i=0;i<n;i++)
{
printf("%d"\n ,a[i]);
}
}
I have not understood your solution but if you want to print maximum and minimum number then you may sort the array and for minimum print array[0] and for maximum print array[lengthOfArray-1].
After hours of debugging it is finally working.
But the original code from where i am learning is still not working.
After i have modified the code upto much extent it is working.
I am currently learning from nptel.ac.in ,hope you people know about nptel.
The course is from IIT Kharagpur and course name is- Programming and Data Structures.
I am currently completed it’s 5th lecture ,the link is- http://nptel.ac.in/courses/106105085/5
Well still the original code from where i am learning is not working.I have provided the link to the video tutorial above.The link to original code that is not working on my computer but working on the proffesor’s computer is- link text
Why is this code not working on my computer properly. I am using Dev C/C++ compiler on windows 7.