Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10

Thread: Code Problem

  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Code Problem

    I was messing around trying to make a code and i did this simple multipcation code:
    Code:
    #include <iostream.h>
    
    int multiply()
    {
        
        int number1;
        int number2;
        int multiplydone;
        cout<<"Type the first number:\n";
        cin>>number1;
        cout<<"Type the second number:\n";
        cin>>number2;
        multiplydone = number1 * number2;
        return multiplydone;
    }
    int main()
    {
        int answer;
        answer = multiply();
        cout<<"The answer is:"<<answer;      
        system("PAUSE")
        return 0;
    }
    can somsone tell me whats wrong if any thing is wrong?

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,280
    Thanks
    4
    Thanked 83 Times in 82 Posts
    If you don't know if anything is wrong then why are you asking a question about it? You need to tell us what the problem is.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    #include <iostream.h>


    int multiply(void);
    int multiply(void)
    {

    int number1;
    int number2;
    int multiplydone;
    cout<<"Type the first number:\n";
    cin>>number1;
    cout<<"Type the second number:\n";
    cin>>number2;
    multiplydone = number1 * number2;
    return multiplydone;
    }
    int main()
    {
    int answer;
    answer = multiply();
    cout<<"The answer is:"<<answer;
    system("PAUSE")
    return 0;
    }


    i donno c++ but you have to add the bold line in C

  • #4
    New Coder dragon's Avatar
    Join Date
    May 2003
    Location
    Florida
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That shouldn't be necessary for C++.

    By the way, Unknown, why don't you just compile the code and see if there are any problems? Although I believe you're missing a semi-colon in the main().
    Last edited by dragon; 01-28-2004 at 02:17 PM.

  • #5
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thx dragon it was the semi colon I hate those.

  • #6
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    On system() again? Hehe, I picked up that mistake last time!
    Omnis mico antequam dominus Spookster!

  • #7
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ya I made sure that i put it the first time I compiled it. But when I took out the system() and put it back in i forgot to put the ;
    Last edited by Unknown; 01-28-2004 at 06:10 PM.

  • #8
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Make sure you read our posting guidelines before you start new thread so you can properly name it. "Code Problem" doesn't say much considering the his a development help forum.
    OracleGuy

  • #9
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    There isnt a forum that says C++. So I resolved to this since its the closest thing.

  • #10
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Well, that wasn't the thing he objected to. This is the correct forum to ask such questions in. The thing he objected to was the title you gave your post.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •