Hi I missed this on an exam - I dont know why we needed to call by reference and
ID: 3690953 • Letter: H
Question
Hi I missed this on an exam - I dont know why we needed to call by reference and why subtracting slopes
This is C++
thanks
#include <iostream>
using namespace std;
void line_inter(double,double,bool &);
int main()
{
double m1, m2;
bool yes_no;
cout << "Enter the slopes of line 1 and line2: ";
cin >> m1 >> m2;
line_inter(m1,m2,yes_no);
if (yes_no)
cout << "The lines do intersect. ";
else
cout << "The lines don't intersect. ";
return 0;
}
void line_inter(double m1, double m2, bool &yes_no)
{
if (m1 - m2 == 0)
yes_no = false;
else
yes_no = true;
}
Explanation / Answer
It is not compulsory to use call by reference
We can do with normal method also