To BIG!!
/*******************************
* CACULATOR
*CREATOR:Sevak
*DATE OF CREATION: 01/09/03 09:26
*DATE OF REVISON: -
*FUNCTIONS: Add,Subtract,Multiply,Divide
*REASON CREATED: To practice C++.
*USAGE: Basic Math
*
********************************/
/**Include Files**/
#include <iostream>
#include <stdlib.h>
/**Include Files**/
/*****Namespace****/
using namespace std;
/*****Namespace****/
/***************Functions*******************/
float Add(float a,float b){return a+b;}
float Subtract(float a,float b){return a-b;}
float Divide(float a,float b){return a/b;}
float Multiply(float a,float b){return a*b;}
int Body()
{//Begin Body
//Body Variables
short Choice;
float number1,number2,result;
//Body Variables
while(1)
{//Begin While loop 1
cout << "\n\t\t\t 4 function Caculator\n"
<< "\n1.Add\n2.Subtract\n3.Multiply\n4.Divide\n5.Exit"
<< "\nPlease choose what you want to do:";
cin >> Choice;
switch(Choice)
{//Begin Choice switch
case 1:
cout << "Enter first number to add: ";
cin >> number1;
cout << "Enter second number to add: ";
cin >> number2;
result = Add(number1,number2);
cout << number1 << " + " << number2 << " = "
<< result << endl;
break;
case 2:
cout << "Enter first number to Subtract: ";
cin >> number1;
cout << "Enter second number to Subtract: ";
cin >> number2;
result = Subtract(number1,number2);
cout << number1 << " - " << number2 << " = "
<< result << endl;
break;
case 3:
cout << "Enter first number to Mulitply: ";
cin >> number1;
cout << "Enter second number to Multiply: ";
cin >> number2;
result = Multiply(number1,number2);
cout << number1 << " * " << number2 << " = "
<< result << endl;
break;
case 4:
cout << "Enter first number to Divide: ";
cin >> number1;
cout << "Enter second number to Divide: ";
cin >> number2;
result = Divide(number1,number2);
cout << number1 << " / " << number2 << " = "
<< result << endl;
break;
case 5:
return 0;
default:
cout << "Error: Invalied Command\n";
break;
}//End Choice switch
}//End While loop 1
}//End Body
/***************Functions*******************/
/***************Main*******************/
int main()
{//Begin Main
Body();
return 0;
}//End Main
/***************Main*******************/
This simple caculator program takes about 440kb. That seems pretty big. Im using DevC++. Is that normal?O ya and can someone tell me how to create one of those white boxes in a post so i can put my coding in it and it wont look so big.
Do you really need #include <stdlib.h> ? that will increase the size a bit, plus it should be cstdlib if it is needed
use [] tags with source and /source in them to add code.
[edited by - quant on September 1, 2003 3:38:55 PM]
use [] tags with source and /source in them to add code.
[edited by - quant on September 1, 2003 3:38:55 PM]
I took out that but still its stuck on 440kb. It probably went down a few hundred bits but no kb.
You need to turn off 'Debug Output Generating' and in the 'Linker Command Line' (orsomething like it) you need to add '-s'. Read the DevCpp FAQs or search the DevCpp forums.
[...] Here it is: [...]
Project Options ->
Parameters ->
Linker ->
Add '-s'.
&
Project Options ->
Compiler ->
1) Linker -> Generate Debugging Information = No
2) Optimization = Yes
3) Optimization -> Best Optimization = Yes
Rebuild your project.
.lick
[edited by - Pipo DeClown on September 1, 2003 3:56:04 PM]
[...] Here it is: [...]
Project Options ->
Parameters ->
Linker ->
Add '-s'.
&
Project Options ->
Compiler ->
1) Linker -> Generate Debugging Information = No
2) Optimization = Yes
3) Optimization -> Best Optimization = Yes
Rebuild your project.
.lick
[edited by - Pipo DeClown on September 1, 2003 3:56:04 PM]
Did you use optimization? You are using floats which take up a little bit more. That might be why.
Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis
Scott Simontis
e-mail:ageofscott@comcast.net
AIM:ssimontis
#including things you don''t need doesn''t increase code size.
Switching your namespace designations doesn''t increase code size.
And of course he''s using floats. It''s a calculator.
You just need to turn on optimizations and turn off debug output.
I like pie.
Switching your namespace designations doesn''t increase code size.
And of course he''s using floats. It''s a calculator.
You just need to turn on optimizations and turn off debug output.
I like pie.
I''ve noticed that Dev-CPP files are always a little bloated. My Win32 program that doesn''t do anything is 100 kb. I really wish there was a way to get it smaller...
quote:Original post by Pipo DeClown
You need to turn off ''Debug Output Generating'' and in the ''Linker Command Line'' (orsomething like it) you need to add ''-s''. Read the DevCpp FAQs or search the DevCpp forums.
Ill second that.
quote:Original post by Pipo DeClown
Guys it''s about compile/linking optimization, not code optimization.
And that!.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement