Search This Blog

Friday, October 7, 2011

Write a program to find max and min of set of real num using for loop

   1:  #include<stdio.h>
   2:  #include<conio.h>
   3:  void main()
   4:  {
   5:  int n,i;
   6:  float max,min,x;
   7:  max=-1.0E38;
   8:  min=1.0E38;
   9:  clrscr();
  10:  printf("Enter the amount of num you want to enter");
  11:  scanf("%d",&n);
  12:  for(i=1;i<=n;i++)
  13:  {
  14:  printf("Enter the real num:");
  15:  scanf("%f",&x);
  16:  if(x%2==0)
          {
          if(x>=max)
          max=x;
          if(x<=min)
          min=x;
          }
  20:  }
  21:  printf("\nThe max num is %f\n",max);
  22:  printf("the min num is %f\n",min);
  23:  getch();
  24:  }

No comments:

Post a Comment