开发者

what is the wrong wih my code? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_Python百科 Closed 11 years ago.
#include <iostream> 

using namespace std;

float sum(float a,float b);

float subs(float a, float b);

float multiple(float a, float b);

float division(float a, float b);

int main()

{//main

    int a,b;

    char o ;
    cout<<"input your calculation with  operation (+,-,/,*) such as 5+6 : /n ";
    cin >> a >> o >> b ;
    switch('o')
    {
    case '+':

        sum(float a, float b);
        break;

    case '-':

        subs(float a, float b);
        break;

    case '*':

         multiple(float a, float b);
        break;

    case '/':

         division(float a, float b);
        break;

    default :
        cout << "error, try again " <<endl;

    }
    return 0;
}//main

float sum(float a,float b)
{//sum

    float total= a+b;
    return total;
}//sum

float subs(float a, float b)
{//subs

    float total=a-b;
    return total;
}//subs     

float multiple(float a, float b)
{//multiple

    float total=a*b;
    return total;
}//multiple

float division(float a, float b)
{//division

    float total=a/b;


Superficially, you're missing a curly bracket at the end. Operationally, your switch statement is switching on a constant, 'o', instead of the variable o.


Change:

switch('o')

to

switch(o)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜