Search This Blog

Friday, October 7, 2011

Write a program to enter a set of num and find largest and smallest even num re-entered

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

No comments:

Post a Comment