#include <iomanip>
#include <cmath>
#include <fstream>
#include <string>
#include<string>
#include<iostream>
using namespace std;
int main()
{
int num1 = 0;
int num2 = 0;
char again = 'y';
while (again=='y')
{
cout<<"Please enter two numbers to compare "<<endl;
cin>>num1>>num2;
cout<<"The two numbers entered in order were "<<num1<<" and "<<num2<<endl;
if (num1<num2)
{
cout<<num2<<" is the larger of "<<num1<< " and "<<num2<<endl;
}
else if (num1>num2)
{
cout<<num1<<" is the larger of "<<num1<< " and "<<num2<<endl;
}
cout<<"\n Go again?(y/n): ";
cin>>again;
}
return 0;
}
Good day. My assignment is as follows: Write a c++ program using functions, that will accept 2 numbers from the keyboard and then determine which is
the larger and smaller of the two. There should be two functions:
1. getnumbers
Output within the 1st function should display
The two numbers entered in order were XXX and YYY
2. findbig
Output within the 2nd function should display
XXX is the larger of XXX and YYY
Put the main function within an "again" loop that will continue until the user no longer wants to.(skip a line between each sets output).
Could you please explain to me how i'd go about creating two such functions? I had a bit of problem grasping the concept of functions....thanks. The above program does work, but it doesn't have the two distinct functions as is requested.