I'm fairly new to C++ and I've been reading this book, where I got to the new Chapter- FUNCTIONS..I wanna know the difference between ....
#include<iostream.h>
int findMax(int, int);
int main()
{
int firstnum, secnum, max;
cout<<"\n Enter a Number: ";
cin>>firstnum;
cout<<"Great! Please Enter a second number: ";
cin>>secnum;
max=findMax(firstnum, secnum);
cout<<"\n The Maximum of the two numbers is "<<max<<endl;
return 0;
}
int findMax(int x, int y)
{
int maxnum;
if(x >= y)
maxnum= x;
else
maxnum=y;
return maxnum;
}
***************************and This.......
#include<iostream.h>
main()
{
int firstnum, secnum;
cout<<"\n Please enter first number: ";
cin>>firstnum;
cout<<"\n Please enter second number : ";
cin>>secnum;
if(firstnum > secnum)
cout<<firstnum<<" is larger ";
else
cout<<secnum<<" is larger ";
return 0;
}
Someone please explain in plain english if possible..lol