what am i doing wrong with calculator?

So I am a complete noob at programming this is my very first time actually attempting it. I don't have the slightest clue what im doing I cant stress that enough. I opened up a compiler typed in this code, which is supposedly a calculator I attempt to run it but it says I need to compile it so I try to compile it and I get this message saying error g++ has stopped working. I exited that out and I get a compile status message saying 0 errors 0 warnings and its done. Is their a step im skipping or did I do something wrong?

// Program which performs addition, subtraction, multiplication and subtraction.

#include <iostream>
using namespace std;

// input function
void Input (float &x, float &y);

float a=1.0, b=1.0, result;
char operation;


int main ()
{
cout << "Program which performs addition, subtraction, multiplication and subtraction. \n\n";

cout << "Please input calculation operation (eg. 1 + 2): \n";
cin >> a >> operation >> b;

Input (a,b);

cout << "The answer is: " << result << endl;
system ("pause");
return 0;
}


void Input (float &x, float &y)
{
a = x;
b = y;

switch (operation)
{
case '+':
result = x + y;
break;

case '-':
result = x - y;
break;

case '*':
result = x * y;
break;

case '/':
result = x / y;
break;

default:
cout << "Improper operation. Please input a correct calculation operation: \n";
cin >> a >> operation >> b;
Input (a, b);
}
}
I compiled your program using VS2010 and it appears to operate just fine.

Probably a problem with how you're invoking g++.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Topic archived. No new replies allowed.