Maximum and minimum number of array

Program:

#include<stdio.h>
int main()
{
int num[10],i,max=0,min=0,n;
printf("Enter no. of elements: ");        /* within array size*/
scanf("%d",&n);
printf("Enter %d numbers:\n",n);
for(i=0;i<n;i++)
{
  scanf("%d",&num[i]);
  if(num[i]>max)
  {
  max=num[i];
  }
  if(num[i]<min)
  {
  min=num[i];
  }
}
printf("Maximum = %d \nMinimum = %d",max,min);
return 0;

}

Output:



No comments:

Post a Comment

x^y using recursion

Program: #include<stdio.h> int power(int a,int b); int main() { int x,y,ans; printf("Enter x and y:\n "); scanf(...