Wednesday, 23 April 2014

13. Write a program that will take as input a set of integers and find and display the largest and the smallest values within the input data values.



#include<stdio.h>
#include<conio.h>
void main()
{
          int arr[5],i,j,k,ii;
          clrscr();
          for(i=0; i<5; i++)
          {
                   printf("\n\n\t Enter the Number -> ");
                   scanf("%d",&arr[i]);
          }
          i=arr[0];
          ii=arr[0];
          for(j=0; j<5; j++)
          {
                   if(arr[j]<ii)
                   {
                             ii=arr[j];
                   }
                   if(arr[j]>i)
                   {
                             i=arr[j];
                   }
          }
          printf("\n\n\t\tGreatest value is %d",i);
          printf("\n\n\t\tSmalles value is %d",ii);
          getch();
}

No comments:

Post a Comment