View Full Version : First C++ Program

10-11-2007, 11:06 PM
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...

#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;


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:)

ralph l mayo
10-12-2007, 12:28 AM
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

10-12-2007, 12:34 AM
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.

10-12-2007, 04:25 AM
Build it in release mode, that will actually turn on the compiler optimizations and should give you a nice and lean executable.

10-12-2007, 06:27 AM
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".

10-12-2007, 11:55 AM
thanks for the help guys.. will look in the compiler options...:)