'First input number turns 0 after the executing the codes [closed]

I'm writing a program to generate a line equation using given slope and y-intercept, below are the codes i extracted from my program:

int m,c;
    
    cout<<"m >>";
    cin>>m;
    cout<<endl;
    cout<<"c >>";
    cin>>c;
    cout<<endl;
    
        if (m=0){
            cout<<"y= "<<c; 
        }
        
        else if(m>0){
            if (c>0){
                cout<<"y="<<m<<"x+"<<c;
            }
            else if (c<0){
                cout<<"y="<<m<<"x"<<c;
            }
            else {
                cout<<"y="<<m;
            }
        }
        else {
            if (c>0){
                cout<<"y="<<m<<"x+"<<c;
            }
            else if (c<0){
                cout<<"y="<<m<<"x"<<c;
            }
            else {
                cout<<"y="<<m;
            }
        }
        

When I input 8 8, the output is as follow:

y=0x+8

When I input 8 -8, the output is as follow:

y=0x-8

When I input 0 5, the output is as follow:

y=0x+5

Even when I try adjust the front part of my codes to

cin>>m>>c; 

It doesnt seem helping, which part of my codes has given such error ?

c++


Solution 1:[1]

You are setting m to 0 in the first if check. Should be using == not =.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 GrimStarGaming