[RESOLVED] Why won't this program I made work ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: [RESOLVED] Why won't this program I made work ?

Threaded View

  1. #1
    Join Date
    Sep 2010
    Posts
    1

    [RESOLVED] Why won't this program I made work ?

    I am trying to make a simple calculator program, it's not finished yet, but when i try to "compile and run" it in Dev C++, it says there is 39 errors! How can there be thirty nine??

    So yeah please help me out by reading through this code and telling me what you think could be the problems. The code looks good to me, but I'm only pretty new to C++...





    #include <iostream.h>
    #include <cmath>
    void normalfun(double);
    void specialfun(float);
    void add(float);
    void subtract(float);
    void multiply(float);
    void divide(float);

    /*
    Name: Simple Calculator
    Copyright: 2010
    Author: @@@@@ @@@@@@@@@
    Date: 27/09/10 15:18
    Description: simple application to perform basic calculations
    */

    int main() // main function, calls other functions on request
    {
    using namespace std;

    cout << "Simple Calculator. Written by @@@@@ @@@@@@@@@\n\n";
    cout << "\tType 0 for normal functions";
    cout << "\n\yType 1 for special functions\n";
    double decision;
    cin >> decision; // creates the variable for users input

    if (decision == 0)
    {
    normalfun(double decision2)
    else specialfun(float)
    }

    system("pause");
    return 0;
    }

    void normalfun(double decision2)
    {
    using namespace std;
    cout << "\n\tType 1 for addition,";
    cout << "\n\tType 2 for subtraction,";
    cout << "\n\tType 3 for multiplication,";
    cout << "\n\tType 4 for division\n\n";

    cin >> decision2;
    {
    if (decision2 == 1);
    add();

    if (decision2 == 2);
    subtract();

    if (decision2 == 3);
    multiply();

    if (decision2 == 4);
    divide();
    }
    }

    void specialfun(float) // special function
    {
    using namespace std;
    cout << "This is special function ";
    }

    void add(float add1, add2, addtotal) // addition function
    {
    using namespace std;
    cout << "Enter two numbers ";
    cout << "\nFirst one: \t";
    cin >> add1;
    cout << "\nSecond one: \t";
    cin >> add2;
    addtotal = add1 + add2;
    cout << "\n ---------------------------------------------- " << "\n \t" << add1 << " add " << add2 << " equals " << addtotal << " .";
    }

    void subtract(float sub1, sub2, subtotal) // subtraction function
    {
    using namespace std;
    cout << "Enter two numbers ";
    cout << "\nFirst one: \t";
    cin >> sub1;
    cout << "\nSecond one: \t";
    cin >> sub2;
    subtotal = sub1 - sub2;
    cout << "\n ---------------------------------------------- " << "\n \t" << sub1 << " subtract " << sub2 << " equals " << subtotal << " .";
    }

    void multiply(float mult1, mult2, multtotal) // multiplication function
    {
    using namespace std;
    cout << "Enter two numbers ";
    cout << "\nFirst one: \t";
    cin >> mult1;
    cout << "\nSecond one: \t";
    cin >> mult2;
    multtotal = mult1 * mult2;
    cout << "\n --------------------------------------------- " << "\n \t" << mult1 << " multiplied by " << mult2 << " equals " << multtotal << " .";
    }

    void divide(float div1, div2, divtotal) // division function
    {
    using namespace std;
    cout << "Enter two numbers ";
    cout << "\nFirst one: \t";
    cin >> div1;
    cout << "\nSecond one: \t";
    cin >> div2;
    divtotal = div1 / div2;
    cout << "\n ---------------------------------------------- " << "\n \t" << div1 << " divided by " << div2 << " equals " << divtotal << " .";
    }






    Thanks
    Last edited by Brad Jones; August 13th, 2012 at 10:24 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center