Advertisement Remove all ads

Write a C++ Program to Find the Smallest off Four Given Integers Using Function Min( ) that Returns the Smallest of Four Given Integers. the Function Prototype is as Below Int Min (Int, Int, Int, Int). - Computer Science 1

Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads

Write a C++ program to find the smallest of four given integers using function min( ) that returns the smallest of four given integers. The function prototype is as below int min (int, int, int, int).

Advertisement Remove all ads

Solution

# include <iostream.h>
# include <conio.h>
int min(int, int, int, int);
void main()
{
int w, x, y, z;
cout <<"Enter four integers";
cin >> w >> x >> y >> z;
cout <<“The minimum no’ = <<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;
}
Concept: C++ Programming
  Is there an error in this question or solution?

APPEARS IN

Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×