I Can Add!

This is a discussion on I Can Add! within the C++ Programming forums, part of the General Programming Boards category; I fianally made a program that will add , it wasn't as hard as i thought! Code: #include <iostream> using ...

  1. #1
    Pokemon Master digdug4life's Avatar
    Join Date
    Jan 2005
    Location
    Mystic Island, NJ
    Posts
    91

    I Can Add!

    I fianally made a program that will add , it wasn't as hard as i thought!
    Code:
    #include <iostream>
    
    using namespace std;
    int add ( int x , int y );
    int main ()
    {
      int x;
      int y;  
      cout << "Firt number to add:";
      cin>> x;
      cin.ignore();
      cout << "Second number to add:";
      cin>> y;
      cin.ignore();
      cout << "The sum is:" << add (x , y );
      cin.get();
      }
    int add ( int x , int y )
    {
     return x + y;
    }
    O and what is a php?
    Verbal Irony >>

    "I love english homework!" When really nobody like english homework.
    -Mrs. Jennifer Lenz (English Teacher)

  2. #2
    Registered User
    Join Date
    Feb 2003
    Posts
    62
    Hey Good on you I liked it,
    Your get many people on here that will say things to try and put you off and discourage or say why are you wasting there time, just ignore them!
    If you and me keep it up nothing could stop us, so keep at it.

    PHP by the way is a Internet scripting langrage, in a way some of it looks similar to C++ like the decision and looping commands. Its a nice little langrage.

    Anyway keep up the good work and beware of pointers!!

  3. #3
    Pokemon Master digdug4life's Avatar
    Join Date
    Jan 2005
    Location
    Mystic Island, NJ
    Posts
    91
    Ok, thanks
    o and what is void supposed to do?
    Verbal Irony >>

    "I love english homework!" When really nobody like english homework.
    -Mrs. Jennifer Lenz (English Teacher)

  4. #4
    former member Brain Cell's Avatar
    Join Date
    Feb 2004
    Posts
    472
    o and what is void supposed to do?
    void means "nothing" or "empty". Your add functions isn't 'void' because it returns the sum of x and y. 'void' functions return nothing. Here's a simple example :
    Code:
    void PrintHello()
    {
       cout << "hello" << endl;
    }
    however, don't use 'void' with main. main should always return an int.


    Your get many people on here that will say things to try and put you off and discourage or say why are you wasting there time, just ignore them!
    I never noticed people doing this. Do you mean people who ask you to use code tags and read the faq before posting?

    "langrage" should be "language" by the way
    Last edited by Brain Cell; 02-07-2005 at 02:13 PM.
    My Tutorials :
    - Bad programming practices in : C
    - C\C++ Tips
    (constrcutive criticism is very welcome)


    - Brain Cell

  5. #5
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    Nice program! Next you should try something that can do all 4 operations (/,*,+,-), and let's the user choose which one he wants to do.

  6. #6
    Pokemon Master digdug4life's Avatar
    Join Date
    Jan 2005
    Location
    Mystic Island, NJ
    Posts
    91
    Thats what i am doing right now, Thank you all
    Verbal Irony >>

    "I love english homework!" When really nobody like english homework.
    -Mrs. Jennifer Lenz (English Teacher)

  7. #7
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    Quote Originally Posted by chrismax2
    beware of pointers!!
    This kind of propaganda has to stop. Pointers are simple. Never let anyone else tell you otherwise. If in doubt, read the FAQ.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  8. #8
    C/C++ homeyg's Avatar
    Join Date
    Nov 2004
    Location
    Louisiana, USA
    Posts
    209
    Quote Originally Posted by pianorain
    This kind of propaganda has to stop. Pointers are simple. Never let anyone else tell you otherwise. If in doubt, read the FAQ.
    Very true.

  9. #9
    C Programmer Stack Overflow's Avatar
    Join Date
    Apr 2004
    Posts
    477
    I agree with pianorain,

    Learning pointers is an important part of every C and C++ programmer. Pointers are simple to learn once you grasp the concept. In addition to the FAQ, there is a short tutorial amongst these boards that may be a helpful addition: Learning Pointers


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  10. #10
    Registered User
    Join Date
    Feb 2003
    Posts
    62
    Hey again,
    I never said donít learn pointers I agree pointers, will make programmes work better and they need to be learnt, but I think someone new needs to understand, strings, arrays functions ect, Before they even attempt pointers, they get confusing when new.
    Last edited by chrismax2; 02-07-2005 at 02:39 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Add a dialog box to a tab
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 01-10-2005, 07:38 AM
  2. can not add member error
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 12-02-2004, 12:18 PM
  3. VC++ Resources - Add Existing Item
    By EliMcGowan in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2004, 02:51 PM
  4. Add user without interacting.
    By zahid in forum Linux Programming
    Replies: 3
    Last Post: 12-21-2002, 10:36 PM
  5. how to add a factorial ()
    By correlcj in forum C++ Programming
    Replies: 14
    Last Post: 10-18-2002, 02:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21