Vous êtes sur la page 1sur 1

EX NO : 8.

3 Maximum and minimum of numbers :


Date : 27.3.15

Program :

#include<stdio.h>
main()
{
int*a;
int n,i,j,t;
printf("enter the number of elements");
scanf("%d",&n);
a=(int*)malloc(n* sizeof (int));
printf("enter the array elements");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<1;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("%d",a[i]);
}

output :

bash-4.2$ ./a.out
enter the number of elements 5
enter the array elements
21
14
17
18
7
max number is 21min number is 7