Monday, December 19, 2011

Monday 12/19/11

#include
#include //must include !

int main()
{
using namespace std;
string myName = "Alfred Jensen";
string myStreet = "5127 S. 95th E. Ave";
string myCityStreet = "Tulsa, OK";

cout << myName << endl;
cout << myStreet << endl;
cout << myCityStreet << endl;


return 0;
}


#include
#include

int main()
{
using namespace std;
cout << "Please enter the distance in furlongs" << endl;
int furlong = 0;
cin >> furlong;
int yard = furlong * 220;
cout << endl << "That is " << yard << " yards long";

}


#include
#include

int twoTimes()
{
using namespace std;
string s = "Three blind mice";
cout << s << endl;
cout << s << endl;

return 0;
}

int twice()
{
using namespace std;
string s = "See how they run";
cout << s << endl;
cout << s << endl;

return 0;
}

int main()
{
twoTimes();
twice();

}


#include
#include

int main()
{
using namespace std;
cout << "Please enter the temp. in Celsius" << endl;
double celsius = 0.0;
cin >> celsius;
double fahrenheit = celsius * 1.8 + 32.0;
cout << "That is " << fahrenheit << " in Fahrenheit degrees";
}


#include
#include

int calculateAU(double);

int main(){
double lightYears = 0.0;

using namespace std;
cout << "Enter the distance in light years: " << endl;
cin >> lightYears;
calculateAU(lightYears);
}

int calculateAU(double lightYears)
{
double au = lightYears * 265608;
std::cout << "That is " << au << " in astronomical units." << std::endl;
return 0;
}


#include
#include

int main()
{
using namespace std;
int n_int = INT_MAX;
short n_short = SHRT_MAX;
long n_long = LONG_MAX;

//sizeof operator yileds size of type or of variables
cout << "int is " << sizeof(int) << " bytes." << endl;
cout << "short is " << sizeof n_short << " bytes." << endl;
cout << "long is " << sizeof n_long << " bytes." << endl;

cout << "Maximum Values: " << endl;
cout << " Int: " << n_int << endl;
cout << " Short: " << n_short << endl;
cout << " Long: " << n_long << endl << endl;

cout << "Minimum int value=" << INT_MIN << endl;
cout << "Bits per byte=" << CHAR_BIT << endl;

return 0;
}


#include
#define ZERO 0
#include
int main()
{
using namespace std;
short sam = SHRT_MAX;
unsigned short sue = sam;

cout << "Sam has " << sam << " dollars and Sue has " << sue;
cout << " dollars deposited." << endl;
cout << "Add $1 to each account." << endl << "Now.";
sam = sam + 1;
sue = sue + 1;
cout << "Same has " << sam << " dollars and Sue has " << sue;
cout << " dollars deposited.\nPoor Sam!" << endl;
sam = ZERO;
sue = ZERO;
cout << "Sam has " << sam << " dollars and Sue has " << sue;
cout << " dollars deposited." << endl;
cout << "Take $1 from each account." << endl << "Now";
sam = sam - 1;
sue = sue - 1;
cout << "Sam has " << sam << "dollars and Sue has " << sue;
cout << " dollars deposited. " << endl << "Lucky Sue!" << endl;

return 0;
}

No comments: