Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int n, i, j, k, min, minloc, max, maxloc;
- printf("How Many Inputs? : ");
- scanf("%d",&n);
- int a[n];
- printf("\nNow Start Entering %d Inputs\n",n);
- for(i=0 ; i<n ; i++) //takes inputs
- scanf("%d",&a[i]);
- min=a[0], minloc=0;
- for(i=1 ; i<n ; i++) //finds the minimum value and location
- if(a[i]<min)
- min=a[i], minloc=i;
- printf("Minimum Value %d is in Location %d\n",min,minloc);
- max=a[0], maxloc=0;
- for(i=1 ; i<n ; i++) //finds the maximum value and location
- if(a[i]>max)
- max=a[i], maxloc=i;
- printf("Maximum Value %d is in Location %d\n",max,maxloc);
- for(i=0 ; i<n-1 ; i++) //sorts
- {
- min=a[i];
- for(j=i+1 ; j<n ; j++)
- if(min>a[j])
- {
- min=a[j];
- a[j]=a[i];
- a[i]=min;
- }
- }
- printf("Sorted Array: ");
- for(i=0 ; i<n ; i++) //prints
- printf("%d ",a[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement