It was good exercise because I did not know how to use command line arguments using visual studio. Anyway, here is my code and feel free to ask question or leave comments.
#include <iostream>
using namespace std;
#define left atoi(arg[1])
#define right atoi(arg[3])
#define OPERAND arg[2]
int main(int argc, char* arg[]){
int setOperand = 0;
int res=0;
if(!strcmp(OPERAND,"+")){
setOperand=1;
}
else if(!strcmp(OPERAND,"-")){
setOperand=2;
}
else if(!strcmp(OPERAND,"*")){
setOperand=3;
}
else if(!strcmp(OPERAND,"/")){
setOperand=4;
}
switch(setOperand){
case 1:
res=left + right;
cout<<res<<endl;
break;
case 2:
res=left - right;
cout<<res<<endl;
break;
case 3:
res=left * right;
cout<<res<<endl;
break;
case 4:
res=left / right;
cout<<res<<endl;
break;
default:
cout<<"<number> <+-x/> <number>"<<endl;
}
}