Functions

This is a discussion on Functions within the C++ Programming forums, part of the General Programming Boards category; Based on : Cprogramming.com Tutorial: Functions Code: #include <iostream> using namespace std; int mult ( int x, int y ); ...

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    1

    Functions

    Based on : Cprogramming.com Tutorial: Functions

    Code:
    #include <iostream>
    
    using namespace std;
    
    int mult ( int x, int y );
    
    int main()
    {
      int x;
      int y;
      
      cout<<"Please input two numbers to be multiplied: ";
      cin>> x >> y;
      cin.ignore();
      cout<<"The product of your two numbers is "<< mult ( x, y ) <<"\n";
      cin.get();
    }
    
    int mult ( int x, int y )
    {
      return x * y;
    }
    Can't understand whats the point of using the int mult ( int x, int y ) instead of

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main()
    {
      int x;
      int y;
      
      cout<<"Please input two numbers to be multiplied: ";
      cin>> x >> y;
      cin.ignore();
      cout<<"The product of your two numbers is "<< (x * y) <<"\n";
      cin.get();
    }
    Need some explanation on whats the point of using int mult ( int x , int y ) and hopefully some example on where they use it on. Thanks in advance

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,114
    There is no point other than to demonstrate a very simple function.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array of functions
    By frktons in forum C Programming
    Replies: 29
    Last Post: 06-30-2010, 10:51 AM
  2. Need help with functions
    By jusfry01 in forum C Programming
    Replies: 2
    Last Post: 05-22-2010, 07:25 PM
  3. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 06:30 PM
  4. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 12:50 PM
  5. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM

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