# C++ Program Examples | Restaurant Menu Program & Simple Calculator

C++ Program Examples. This question is once asked in “Nepal Programmers Community”, Programmers Official Community. I have solved the problems and provided the answers here with code.  I hope, this will help you to understand how to solve these problems in C++ using functions. Program Code for Question 1.

#include<iostream>
#include<conio.h>

#define B 200;
#define F 50;
#define P 500;
#define S 150;

using namespace std;

void takecustomerdata();

int main()
{

takecustomerdata();

getch();
return 0;
}

{
cout<<“B-Burger”<<endl;
cout<<“F-French Fries”<<endl;
cout<<“P-Pizza”<<endl;
cout<<“S-Sandwich”<<endl;
}

void takecustomerdata()
{

int quantity;
char type;
double charge;

cout<<“Enter Food Type and Quantity ? Food Type [B or F or P or S]”<<endl;
cin>>type>>quantity;

cout<<“You ordered “<<quantity<<” “<<type<<endl;

switch(type)
{
case ‘B’:
charge = quantity * 200;
cout<<“Total Charge: “<<charge<<endl;
break;

case ‘F’:
charge = quantity * 50;
cout<<“Total Charge: “<<charge<<endl;
break;
case ‘P’:
charge = quantity * 500;
cout<<“Total Charge: “<<charge<<endl;
break;
case ‘S’:
charge = quantity * 500;
cout<<“Total Charge: “<<charge<<endl;
break;
default:
cout<<“You entered invalid type!”;
}
}

Program Code for Question 2.

/* Program to make a simple calculator to Add, Subtract, Multiply and Divide using functions*/
#include<iostream>
#include<conio.h>
using namespace std;

void simplecalculator();

int main()
{
simplecalculator();
}

void simplecalculator()
{
char c;
cout<<“Enter Operation [+,-,*,/] \n”;
cin>>c;

cout<<“Enter any two numbers”<<endl;
cin>>a>>b;

switch(c)
{
case ‘+’:
break;

case ‘-‘:
sub = a – b;
cout<<“Subtraction of two number is “<<sub<<endl;
break;

case ‘*’:
mul = a * b;
cout<<“Multiplication of two number is “<<mul<<endl;
break;

case ‘/’:
div = a / b;
cout<<“Division of two number is “<<div<<endl;
break;

default:
cout<<“Invalid Input”<<endl;

}
}

I have used Dev C++ Compiler while solving these programs.

In above program, I have just used Switch Case Statement, Functions, and Basic input/output functions of c++ programming. I think you have understood the concepts very well.

## 3 Replies to “C++ Program Examples | Restaurant Menu Program & Simple Calculator”

1. Tetsuya says:

Hi, I’ve try this and it aint working

1. Codeprogramming says:

what was an error message while running this code. Send error message or screenshots on codeprogramming.org@gmail.com, we will try to resolve it.

2. 카지노사이트 says:

Hurrah, that’s what I was looking for, what a material! existing here at this website,