C++ Function Definition sets smaller of two numbers to 0

Description

C++ Function Definition sets smaller of two numbers to 0

#include <iostream>
using namespace std;
int main()//  w  ww. ja va2s  . c  o  m
{
   void zeroSmaller(int&, int&);
   int a=4, b=7, c=11, d=9;
   zeroSmaller(a, b);
   zeroSmaller(c, d);
   cout << "\na=" << a << " b=" << b
   <<  " c=" << c << " d=" << d;
   return 0;
}
// sets the smaller of two numbers to 0
void zeroSmaller(int& first, int& second)
{
   if( first < second )
      first = 0;
   else
      second = 0;
}



PreviousNext

Related