switch

hi everyone...i want to ask for your help in my programming problem here..
this coding i made can be compiled, but it can't run properly...so, your help would be highly appreciated...thank you..


#include <iostream>
using namespace std;

int main ()

{
float num1,num2,num3;
float add,minus, product;
int symbol;

cout<<" Enter number 1: " ;
cin>> num1;

cout<<" Enter number 2: ";
cin>> num2;

cout<<" Enter number 3: ";
cin>>num2;

cout<<" enter operation: ";
cin>> symbol;



switch(symbol)
{
case '+': add= num1+num2+num3;
cout<<" Addition = " <<endl;
break;
case '*': product= num1*num2*num3;
cout<<" Product = "<< product <<endl;
break;
case '-': minus= num1-num2-num3;
cout<<" Substract = "<< minus <<endl;
break;
default : cout<<"unknown application"<<endl;
break;

}

system ("pause");
return 0;
}
Use a char for the symbol.

Also, instead of three floats for the answers, you can just have one and then update it accordingly:
1
2
3
4
5
6
7
8
float answer;
//code
switch(symbol)
{
case '+': answer = num1 + num2 + num3;
//Other cases
}
std::cout<<answer;
thnx man..:)
Topic archived. No new replies allowed.