2 Aug 2019

  • August 02, 2019
  • Amitraj

/* C Program to find biggest and smallest no. in a given array*/

http://codevidyalay.blogspot.com 

#include<stdio.h>
void biggest(int a[],int n);
void smallest(int a[],int n);
int main()
{
int i,n,a[100];
printf("Enter a no:");
scanf("%d",&n);

printf("Enter %d no.s:",n);
for(i=0;i<n;i++)
scanf("%d", &a[i]);

biggest(a,n);
smallest(a,n);
return 0;
}
void biggest(int a[],int n)
{
int big,i;
big=a[0];
for(i=1;i<n;i++)
{
if(big<a[i])
big=a[i];
}
printf("Biggest is %d\n",big);
}
void smallest(int a[],int n)
{
int small,i;
small=a[0];
for(i=1;i<n;i++)

{
if(small>a[i])
small=a[i];
}
printf("Smallest is %d",small);
}


INPUT/OUTPUT:
Enter a no:5
Enter 5 no.s:4 5 8 0 9
Biggest is 9
Smallest is 0





Translate

Popular Posts