Functions

This is a discussion on Functions within the C++ Programming forums, part of the General Programming Boards category; I tried making a function to get used to them, but this code does not work. What's wrong with it? ...

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

    Functions

    I tried making a function to get used to them, but this code does not work. What's wrong with it?

    Code:
    #include <iostream.h>
    int mult(int x);
    int main()
    {
      int x;
      cout << "Please give a number for 'X'";
      cin >> x;
      cout << "X + 1 is " << mult(X);
      return 0;
    }
    int mult(int x)
    {
      return x;
    }
    thanks alot for any help

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    47
    You just have a typo

    This Line is WRong!!
    Code:
     cout << "X + 1 is " << mult(X);
    Remember case sensitive;
    Code:
     cout << "X + 1 is " << mult(x);
    Make the x lowercase

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, 06:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 12:50 PM
  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, 02:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 06:39 AM

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