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 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 2 Times in 2 Posts

    First C++ Program

    hi guys .... i am new to programming and this is my first C++ program... the only problem i have is that the size is large...almost 5MB... is there anything that can help me to reduce the size?

    here is my source...

    Code:
    #include <iostream>
    
    
    int main()
    
    {
    
    float number1,number2;
    
    float sum,subtract,product,division;
    
    std::cout <<"Enter the value of number1 :";
    std::cin >>number1;
    std::cout <<"Enter the value of number2 :";
    std::cin >>number2;
    
    sum=number1+number2;
    subtract=number1-number2;
    product=number1*number2;
    division=number1/number2;
    
    std::cout <<"sum is :"<<sum <<std::endl;
    std::cout <<"subtract is :"<<subtract <<std::endl;
    std::cout <<"product is :"<<product <<std::endl;
    std::cout <<"division is :"<<division <<std::endl;
    
    return 0;
    
    }
    any help will be appreciated
    Mind Surfer

  • #2
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    5MB is the size of the executable? What compiler are you using? Sounds like it's linking a bunch of extraneous crap. The executable is 13k with gcc

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 2 Times in 2 Posts
    well i am using MSVC++ 6.0... i also made other program but it also ends up with 5MB in size... the size of the executable alone is 512KB...but the whole debug folder is like 5MB.
    Mind Surfer

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Build it in release mode, that will actually turn on the compiler optimizations and should give you a nice and lean executable.
    OracleGuy

  • #5
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,638
    Thanks
    2
    Thanked 404 Times in 396 Posts
    It's 37k using VC++ 2008 in Debug mode. I think ralph might be correct about "Sounds like it's linking a bunch of extraneous crap".

  • #6
    New Coder
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 2 Times in 2 Posts
    thanks for the help guys.. will look in the compiler options...
    Last edited by mindsurfer; 10-12-2007 at 01:33 PM.
    Mind Surfer


  •  

    Posting Permissions

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