### loop whole program

/* Create a calculator program using function method.
Your calculator layout are as follows:

2: Substrak
3: Multiply
4: Division */

#include<iostream>
using namespace std;

int calculate(int A, int B);
int A=0, B=0, Total=0, value=0;
char y, n, choice;

int main()
{

cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~\n";
cout<<"Welcome to Nicholas Calculator :) \n";
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~\n";

do{
cin>> A;
cin>> B;
cout<<" 1) Add +\n 2)Substrak -\n 3)Multiply X\n 4)Division / \n\n";
cout<<"Operation:";
cin>>value;
calculate(A, B);

do{
cout<<" Continue Y/N: ";
cin>>choice>>y>>n;
}while(choice!=y && choice==n );

}while(choice != n );

system("Pause");
return 0;

}

int calculate(int a, int b)
{
switch(value)
{ case 1: Total=a+b;
cout<<"Total:"<<Total<<"\n";
break;

case 2: Total=a-b;
cout<<"Total:"<<Total<<"\n";
break;

case 3: Total=a*b;
cout<<"Total:"<<Total<<"\n";
break;

case 4: Total=a/b;
cout<<"Total:"<<Total<<"\n";
break;

default:

}
 ``1234567`` ``````char yn; do { //program code here std::cout << "Run again? Y/N: " << std::flush; }while(std::cin >> yn && (yn == 'Y' || yn == 'y'));``````