Thread: Help with functions

  1. #1
    Registered User
    Join Date
    Sep 2005

    Help with functions

    Ok. I'm doing this site's tutorial on C++, and I'm on the lesson about functions. I'm trying to do the multiplication example. But it won't work. here's what i have
    //a program to test out this whole idea of functions
    #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;
    	cout<<"the product of your two numbers "<< mult (x,y) << "\n";
    int mult (int x, int y)
    	return x*y;
    When i copy and paste it in, it works just fine. What am i doing wrong?

    Never mind. I figured out what i was doing wrong. I need to put a ; after namespace std
    Last edited by KittyKun; 09-29-2005 at 06:17 PM.

  2. #2
    C++ Enthusiast jmd15's Avatar
    Join Date
    Mar 2005
    Well this could be one problem:
    Quote Originally Posted by KittyKun
    using namespace std
    You left the semi-colon off, it should be this:
    using namespace std;
    Otherwise it looks pretty good, I will go ahead and compile it now just to make sure.

    Yep, works for me.
    Trinity: "Neo... nobody has ever done this before."
    Neo: "That's why it's going to work."

  3. #3
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Seattle, WA
    Missing semicolon after "using namespace std"

    Edit: Beaten
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM