提问者:小点点

我正在尝试用C++创建一个货币转换程序,我不知道如何继续


#include <iostream>

using namespace std;

int Convert(int dollars)
{
    int amount = dollars * 113;
    cin >> dollars;
} 

int main ()
{
    Convert ();
    count << "Enter the amount you want to convert";
}

共1个答案

匿名用户

您的程序存在多个问题,首先它需要一个您没有提供的参数,将cin移动到main并将输入发送到convert()函数。 然后,返回转换并打印它。

#include <iostream>

using namespace std;

int Convert(int dollars)
{
    return (dollars * 113);
} 

int main ()
{
    int amount;
    cout << "Enter the amount you want to convert and press enter ";
    cin >> amount;
    cout << "Result is = " << Convert(amount) << endl;
    return 0;
}

相关问题


MySQL Query : SELECT * FROM v9_ask_question WHERE 1=1 AND question regexp '(尝|试用|c++|创建|货币|转换|程序|不知道)' ORDER BY qid DESC LIMIT 20
MySQL Error : Got error 'repetition-operator operand invalid' from regexp
MySQL Errno : 1139
Message : Got error 'repetition-operator operand invalid' from regexp
Need Help?