Jump to content
Welcome, Guest
Existing user? Sign In

Sign In



Sign Up
The MatriX
  • Welcome To Ghbsys
  • CS GO Streaming Version is released. Have fun streaming while cheating!
  • Have a Payment Issue? Send us a Support ticket.
  • Make a thread if you need support or join our discord for live support.
  • Have Suggestions? Make a thread and you'll earn Ghbsys Points for implemented suggestions.
  • Join our discord to stay well connected! Don't forget to integrate your discord to the site
  • Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum

    Welcome to [GHB] - GAmEhAcKbAsTaRdS Forum, like most online communities you must register to view or post in our community, but don't worry this is a simple free process that requires minimal information for you to signup. Be apart of [GHB] - GAmEhAcKbAsTaRdS Forum by signing in or creating an account.
    • Start new topics and reply to others
    • Subscribe to topics and forums to get email updates
    • Get your own profile page and make new friends
    • Send personal messages to other members.

    How to make a Basic Calculater


    PhoenixRaider
     Share

    Recommended Posts

    First you go make a new Wind32 Console EMPTY Project.

    Then,

    You create a new file in the project (.cpp) and name it main.cpp.

    When you click on your main.cpp file .. it should be blank.

    If not , you did something wrong.

     

    Lets start with the coding.

     

    At the top include windows.h like this.

    #include <windows.h>

     

     

     

    This is an important part.You must specify to your compiler that you want to be using name space STD.So you do it like this below the #include.

     

     using namespace std;

    Now we need to get our function because all coding must be in a function or it will give you errors.

     

    Type in ..

     

     

     

    int Main(void)
    
    {
    
     return 0;
    }

     

     

     

    Now to add a Name to your Window you will have to do it like this.

     

     

     

    system("TITLE Tutorial - 101");

     

     

     

    Now that will make your window be named ..Tutorial - 101

     

    Lets say you don't like the font or the background your window has and you want to change it.You do the following:

     

     

     

    system("COLOR 1f");

     

     

     

    The 1 stands for the color that you want your FONT to be.The f stands for the color that you want your BACKGROUND to be.

     

    Now if you did it correctly .. you should have no errors and be ready to move to the next step.

     

    Now you want to define our 2 variables.You may call them what ever you like but for this tutorial I will be using firstv and secondv.To do that in C++ you must do the following.

     

     

     

    double firstv;
    double secondv;

     

     

     

    Now we need to make it print some text that asks you for your first Variable.How to do it ? :D Easy. xD You will use cout to do it.Like this:

     

     

    cout << "Please enter the first number:" << endl << endl;

     

     

    Now that will print the text , Please Enter the first number .I added the endl after so its not all cramed.endl stands for End Line.

     

    Now we want it to remember the number that will be inputed.We will store it in our first variable that you defined above.Like this:

     

     

     

    cin >> firstv;

     

     

     

    That will save the number that you type (must be an element of N) into firstv.So when we call firstv it will use the number that you inputed O.o

     

    Now you do the same thing that you did for it to print the first number but now you want it to print this, Please enter the second number: I won't explain this line of code since I already did above.

     

     

     

    cout << "Please enter the second number:" << endl << endl;

     

     

     

    After doing that , you want to do same thing as above again.To input the number typed in there in secondv.Like this:

     

     

     

    cin >> secondv;

     

     

     

    I won't explan that line since I explained it before.

     

    Now if you followed closely you shouldn't have any errors.If you do , then redo the tutorial.

     

    Next step,

     

    Here is where the real math will be done ;)

     

    First you want to print your text saying , The answer is:

     

    Then let the program do the math like this.

     

     

    cout << "The answer is:" << (firstv + secondv) << endl << endl

     

     

     

    The real math is this .. (firstv + secondv) ... There is nothing else that does math in this whole code just that little thing.

     

     

     

    now remember .. you must put all that in ..

     

     

     

    int Main(void)
    
    {
    
    
    
       return 0;
    
    }

     

     

     

    Tutorial was written by Str1k3r21 A.K.A. PhoenixRaider

    If you release this on other sites give me credits.

    Edited by PhoenixRaider
    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...