菜单驱动的界面C语言,菜单驱动的C ++程序,用于简单的计算器

在本教程中,我们将讨论为简单计算器创建菜单驱动程序的程序。

该程序将使用户能够在以下数学运算中进行选择-加,减,乘,除,HCF和LCM。

示例#include 

using namespace std;

//显示菜单

void menu(){

cout <

cout <

cout <

cout <

cout <

cout <

cout <

}

//计算输出结果

void result(int choice, int a, int b){

switch (choice) {

case 1: {

cout <

break;

}

case 2: {

cout <

break;

}

case 3: {

cout <

break;

}

case 4: {

cout <

break;

}

case 5: {

cout <

break;

}

case 6: {

cout <

break;

}

case 7: {

cout <

break;

}

default:

printf("Wrong Input\n");

}

}

int main(){

int a = 5, b = 7;

int choice, res;

menu();

cout <

choice = 1;

cout <

result(choice, a, b);

return 0;

}

输出结果Press 1 to calculate Sum of Numbers

Press 2 to calculate Difference of Numbers

Press 3 to calculate Product of numbers

Press 4 to calculate Division of numbers

Press 5 to calculate HCF of numbers

Press 6 to calculate LCM of numbers

Press 7 to exit

Enter your choice:

Choice is 1

Sum is 12

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值