Program that returns the minimum of 4 integers


     # include <iostream.h>
     int min (int, int, int, int);
     void main( )
     {
    int w, x, y, z;
    cout<<"\n Enter four integers : ";
    cin>>w>>x>>y>>z;
    cout<<"\n Their minimum is "<<min(w,x,y,z)<<endl;
      }
    int min ( int n1, int n2, int n3, int n4)
    {
        int min = n1;
        if (n2 < min) min  =  n2 ;
        if (n3 < min) min  =  n3 ;
        if (n4 < min) min  =  n4 ;
        return min;
       }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|