if else语句出现问题
我设计了一个简易计算器,但是if else语句出问题了,无论输入什么数字都进行加法运算,下附程序#include<iostream>
#include<cstdlib>
using namespace std;
int main(){
double a=0,b=0,c=0,d=0;
cout<<"请选择所需要的功能。"<<endl;
cout<<"1-----加"<<endl;
cout<<"2-----减"<<endl;
cout<<"3-----乘"<<endl;
cout<<"4-----除"<<endl;
cin>>c;
if(c=1)
{
cout<<"请输入数字a:";
cin>>a;
cout<<"请输入数字b:";
cin>>b;
d=a+b;
cout<<"计算结果是:";
cout<<d;
}else if(c=2)
{
cout<<"请输入数字a:";
cin>>a;
cout<<"请输入数字b:";
cin>>b;
d=a-b;
cout<<"计算结果是:";
cout<<d;
}else if(c=3){
cout<<"请输入数字a:";
cin>>a;
cout<<"请输入数字b:";
cin>>b;
d=a*b;
cout<<"计算结果是:";
cout<<d;
}else if(c=4){
cout<<"请输入数字a:";
cin>>a;
cout<<"请输入数字b:";
cin>>b;
d=a/b;
cout<<"计算结果是:";
cout<<d;
}
return 0;
system("pause")
}