Chắc suất Đại học top - Giữ chỗ ngay!! ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.
Mã code:
#include <iostream>
using namespace std;
int main()
{
int num1,num2;
char pheptinh; //phep tinh nhu +,-,x,:
cout <<"Nhap so dau tien: ";
cin >>num1;
cout <<"Chon phep tinh: +,-,x,/ : ";
cin >>pheptinh;
cout <<"Nhap so tiep theo : ";
cin >>num2;
if (pheptinh == '+') {
cout <<"The result is "<<num1+num2<<endl;
} else if (pheptinh == '-') {
cout <<"The result is "<<num1-num2<<endl;
} else if (pheptinh == 'x') {
cout <<"The result is "<<num1*num2<<endl;
} else if (pheptinh == '/'){
cout <<"The result is "<<num1/num2<<endl;
} else {
cout <<"ERROR! Please check again!";
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int num1,num2;
char pheptinh; //phep tinh nhu +,-,x,:
cout <<"Nhap so dau tien: ";
cin >>num1;
cout <<"Chon phep tinh: +,-,x,/ : ";
cin >>pheptinh;
cout <<"Nhap so tiep theo : ";
cin >>num2;
if (pheptinh == '+') {
cout <<"The result is "<<num1+num2<<endl;
} else if (pheptinh == '-') {
cout <<"The result is "<<num1-num2<<endl;
} else if (pheptinh == 'x') {
cout <<"The result is "<<num1*num2<<endl;
} else if (pheptinh == '/'){
cout <<"The result is "<<num1/num2<<endl;
} else {
cout <<"ERROR! Please check again!";
}
return 0;
}