Results 1 to 5 of 5
  1. #1
    phoenixraider's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    37
    Reputation
    10
    Thanks
    21

    How to make a Basic Addition Calculator + Explenation

    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.
    Code:
    #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.

    Code:
     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 ..



    Code:
    int Main(void)
    
    {
    
         return 0;
    }
    Now to add a Name to your Window you will have to do it like this.



    Code:
    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:



    Code:
    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.



    Code:
    double firstv;
    double secondv;
    Now we need to make it print some text that asks you for your first Variable.How to do it ? :O Easy. You will use cout to do it.Like this:


    Code:
    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:



    Code:
    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

    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.



    Code:
    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:



    Code:
    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.


    Code:
    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 ..



    Code:
    int Main(void)
    
    {
    
     
    
           return 0;
    
    }
    Tutorial was written by Str1k3r21 A.K.A. PhoenixRaider
    If you release this on other sites give me credits.
    My private D3D

    [img]https://i279.photobucke*****m/albums/kk147/crusher233/PR.png[/img]

    X-Mas Hook in Action (version 1.0)
    [YOUTUBE]XET-y-2PZig[/YOUTUBE]

  2. #2
    tokie_'s Avatar
    Join Date
    Sep 2008
    Posts
    6
    Reputation
    10
    Thanks
    0
    i wear man im not tring to flame on you or anything but you need to rember to include
    #include <iostream>
    that is for your baisc input out put header you
    cout stands for console output and cin for console input

    but i guess it really depends on what version of C++ their using how their going to compile it and how their going to run the exe file

  3. #3
    therofl's Avatar
    Join Date
    Feb 2008
    Gender
    male
    Posts
    76
    Reputation
    9
    Thanks
    9
    Quote Originally Posted by tokie_ View Post

    but i guess it really depends on what version of C++ their using how their going to compile it and how their going to run the exe file
    Idk if thats the case, if you dont include iostream you cant use cout or cin at all.

  4. #4
    phoenixraider's Avatar
    Join Date
    Aug 2008
    Gender
    male
    Posts
    37
    Reputation
    10
    Thanks
    21
    I know it is iostream ..
    But I did a typo and now it wont let me edit my first post


    and yes u can use it without having put
    Code:
    #include <iostream>
    Like this ...
    Code:
    std::cout
    std::cin
    std::endl
    like dat ..
    My private D3D

    [img]https://i279.photobucke*****m/albums/kk147/crusher233/PR.png[/img]

    X-Mas Hook in Action (version 1.0)
    [YOUTUBE]XET-y-2PZig[/YOUTUBE]

  5. #5
    Calster's Avatar
    Join Date
    Dec 2008
    Gender
    male
    Posts
    16
    Reputation
    10
    Thanks
    3
    Im sure using std::cout just makes it so you dont need to put
    Code:
    using namespace std;
    I think you will always need:
    Code:
    #include <iostream>
    to use cout and cin.

    ~Calster~
    ~ Hope i can help ~
    ~ Thank me if i do ~

Similar Threads

  1. How to make a game?
    By Dave84311 in forum General
    Replies: 4
    Last Post: 09-12-2006, 12:33 AM
  2. How to make a working NFV Hack
    By System79 in forum Game Hacking Tutorials
    Replies: 1
    Last Post: 09-04-2006, 04:56 AM
  3. How to make the server run
    By wowhaxor in forum Gunz General
    Replies: 3
    Last Post: 05-25-2006, 09:59 PM
  4. How to make a Zombie
    By arunforce in forum Art & Graphic Design
    Replies: 2
    Last Post: 01-27-2006, 08:07 AM
  5. How I make wallhack?
    By RaidenDXX in forum WarRock - International Hacks
    Replies: 6
    Last Post: 01-23-2006, 01:28 PM

Tags for this Thread