Pass by reference differentiation problem

My task is to write a program with a sub function that will differentiate a polynomial when the user enters 6 integers. Also it should return true if the the result is a nonzero polynomial. When the program is ran it will give me the correct numbers but it doesn't give me the return value. I am not sure if the "if" statement is working correctly.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
using namespace std;  

bool diff_poly (int& a , int& b, int& c, int& d, int& e, int& f){
        a=a*5;
	b=b*4;
	c=c*3;
	d=d*2;
	e=e*1;
	f=f*0;
        if(a+b+c+d+e+f>0)
	{
	  return true;
	}
   return false;
 }
	

int main()
{
    bool diff;
    int a,b,c,d,e,f;
    char again;
    do
    {  // run program untill user wants to stop
      cout<<"\nEnter six integers positive or negative:";
      cin>>a>>b>>c>>d>>e>>f;
      diff=diff_poly(a,b,c,d,e,f);
	if(diff=true){
		cout<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" "<<f<<endl;
      }
       cout<<"\nDo you want to run progaram again? (y/n):"<<endl;
      cin>>again;
    }  
    while((again=='y') || (again=='Y'));
    cout<<"\nBye\n";
    return 0;
}
the correct syntax is
if (diff==true)
It is terrible that I couldn't catch that sometimes it takes another set of eyes. Thanks for the help.
Btw: You can still "optimize" the code:
1
2
3
a *= 5; // instead of a = a *  5;
//...
return (a+b+c+d+e+f>0) ; // instead of if (...) {return true; } return false ; 
Topic archived. No new replies allowed.