Posted by MindBreaker at 2:13 AM
Read our previous post
Object:
Find the smallest number
Source Code:
#include <iostream>
using namespace std;
class
number
{
private:
public:
int
check(int a,int
b, int c)
{
int
ary[3];
ary[0]=a;
ary[1]=b;
ary[2]=c;
int
min=-1;
for(int n=0;n<3;n++)
{
for
(int m=1;m<3;m++)
{
if(ary[n]>ary[m])
{
min=ary[m];
}
}
}
return(min);
}
};
void
main ()
{
/////////
Taking input from user ////////////////////
int
first,second,third,minimum;
cout<<"Enter
First Digit"<<endl;
cin>>first;
cout<<"Enter
Second Digit"<<endl;
cin>>second;
cout<<"Enter
Third Digit"<<endl;
cin>>third;
///////////////
Class obj numb///////////////////////
number numb;
////////////
return from check func of class number//
minimum=numb.check(first,second,third);
cout<<"Smaller
number is : "<<minimum<<endl;
}
Output:
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.