Thread: Help With Parameters

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Is Trying to Learn
    Join Date
    Mar 2006
    Location
    Hutton, Preston
    Posts
    215
    actually i think i got it.

    Code:
    #include <iostream>
    
    using namespace std;
    
    int Number(int a, int b);
    
    int main()
    {
    
    cout <<"Number = " << Number(8,2) <<endl;
    
    system ("pause");
    }
    
    int Number(int a, int b)
    {
    return a,b;
    }
    the only prob now is that it out puts just "2" and not both "2" and "8"
    Last edited by peckitt99; 10-26-2006 at 01:30 PM.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >the only prob now is that it out puts just "2" and not both "2" and "8"
    If you want to add them, then you would do:
    Code:
       return a + b;
    If you want to subtract them, then:
    Code:
       return a - b;
    The idea is: perform some operation on the arguments and return the result.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 6
    Last Post: 07-21-2008, 06:04 AM
  2. function with variable number of parameters
    By mikahell in forum C++ Programming
    Replies: 3
    Last Post: 07-23-2006, 03:35 PM
  3. Additional parameters for operator delete
    By darksaidin in forum C++ Programming
    Replies: 0
    Last Post: 09-21-2003, 11:46 AM
  4. Passing parameters from VB to C++ through ActiveX DLL
    By torbjorn in forum Windows Programming
    Replies: 0
    Last Post: 12-10-2002, 03:13 AM
  5. command-line parameters.
    By Tombear in forum C Programming
    Replies: 2
    Last Post: 10-28-2001, 08:40 AM