Hey I just started learning some C++ programming from the tutorials provided by this website, and I'm trying to make a simple calculator. This is what I have but I'm getting build errors, can anyone help me? I can't seem to find what's wrong.
Code:#include <iostream> using namespace std; int mult ( int x, int y ); int add ( int x, int y ); int div ( int x, int y ); int sub ( int x, int y ); int main() { int x; int y; int option; cout<<"1 - Add\n2 - Subtract\n3 - Multiply\n4 - Divide"; cin>> option; cin.ignore(); if ( option == 1 ) { cout<<"Input the numbers you would like to add.\n"; cin>> x >> y; cin.ignore(); cout<<"The sum is: "<< add ( x, y ) <<".\n"; } else if ( option == 2 ) { cout<<"Input the numbers you would like to subtract.\n"; cin>> x >> y; cin.ignore(); cout<<"The difference is: "<< sub ( x, y ) <<".\n"; } else if ( option == 3 ) { cout<<"Input the numbers you would like to multiply.\n"; cin>> x >> y; cin.ignore(); cout<<"The product is: "<< mult ( x, y ) <<".\n"; } else if ( option == 4 ) { cout<<"Input the numbers you would like to divide.\n"; cin>> x >> y; cin.ignore(); cout<<"The quotient is: "<< div ( x, y ) <<".\n"; } cin.get(); } int add ( int x, int y ) { return x + y; } int sub ( int x, int y ) { return x - y; } int mult ( int x, int y ) { return x * y; } int div ( int x, int y ) { return x / y; }



LinkBack URL
About LinkBacks


