I am receiving the following error and need assistance in correcting my code.
ERROR:
error: jump to case label [-fpermissive]|
error: crosses initialization of 'int diff'|
error: crosses initialization of 'int sum'|
CODE:
#include <iostream>
#include <cmath>
using namespace std;
// display the calculator menu
// Simple Calculator Menu
// ----------------------
// 1. Addition (+)
// 2. Subtraction (-)
// 3. Quit to exit the program
void display_menu();
// function get_choice reads, validates and returns
// the user's choice
int get_menu_choice();
// function gets two integer numbers typed by the user
// function reads the two numbers into a and b which are
// passed by reference
void get_two_numbers(int &a, int &b);
// function add returns a + b
int add(int a, int b);
// function substract returns a - b
int subtract(int a, int b);
int main()
{
int choice;
do
{
display_menu();
choice = get_menu_choice();
int x, y;
switch (choice)
{
case 1: get_two_numbers(x, y);
int sum = add(x, y);
cout << x << " + " << y << " = " << sum << endl;
break;
case 2: get_two_numbers(x, y);
int diff = subtract(x, y);
cout << x << " - " << y << " = " << diff << endl;
break;
default:;
}