Exam Practice!
1. T
Memory Snapshots
Output
Programming Exercises
/*——————————————————————–*/
int main()
/* Exit program. */
return 0;
/* Enter number of meters from the keyboard. */
cout << “Enter the number of meters: \n”;
cin >> meters;
}
/*——————————————————————–*/
int main()
{
/* Declare variables. */
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_24 */
using namespace std;
int main()
{
/* Declare variables. */
double pounds, newtons;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_25 */
/* */
/* Compute the equivalent temperature in degrees Rankin */
/* from the given temperature. */
degrees_R = degrees_F + 459.67;
int main()
{
/* Declare variables. */
double degrees_C, degrees_F, degrees_R;
/* Exit program. */
return 0;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_27 */
/* Compute the equivalent temperature in degrees Fahrenheit */
/* from the given temperature. */
degrees_R = (9.0/5.0)*degrees_K;
degrees_F = degrees_R – 459.67;
/* Print the temperatures. */
cout << degrees_K << ” degrees Kelvin = ” << degrees_F << ” degrees
Fahrenheit \n”;
/* Problem chapter2_28 */
/* */
int main()
{
/* Declare variables. */
double a, b, area;
/* Exit program. */
return 0;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_29 */
int main()
{
/* Declare variables. */
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_30 */
/* */
/* This program finds the area of a circle. */
int main()
{
/* Declare variables. */
double r, area;
/* Enter the radius. */
cout << “Enter the radius of the circle: “;
cin >> r;
/* Exit program. */
return 0;
}
double u, r, area;
/* Enter the lengths of the radii and */
/* the angle between them. */
cout << “Enter the length of the radii and the angle “
<< “(in radians) between them: “;
cin >> r >> u;
/* This program computes the area of a sector of a circle when */
/* the input (d) is the angle in degrees between the radii. */
#include <iostream>
using namespace std;
const double PI = 3.141593;
int main()
{
/* Declare variables. */
double d, r, area, theta;
/* Exit program. */
return 0;
}
{
/* Declare variables. */
double a, b, area;
/* Enter the length of the semiaxes. */
cout << “Enter the length of the semiaxes: “;
cin >> a >> b;
/* Exit program. */
return 0;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_34 */
/* */
#include <iostream>
using namespace std;
const double PI = 3.141593;
<< ” is ” << area << endl;
/* Exit program. */
return 0;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_35 */
int main()
{
/* Declare variables. */
double r, volume;
/* Enter the radius of the sphere. */
cout << “Enter the radius of the sphere: “;
cin >> r;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_36 */
#include <iostream>
using namespace std;
const double PI = 3.141593;
int main()
{
/* Declare variables. */
double r, h, volume;
/* Exit program. */
return 0;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_37 */
int main()
{
/* Declare variables. */
double molecular_weight;
/* Compute the molecular weight of glycine. */
molecular_weight = (2*OXYGEN) + (2*CARBON) +
NITROGEN + (5*HYDROGEN);
using namespace std;
/* Defines symbolic constants for the appropriate atomic weights. */
const double OXYGEN = 15.9994;
const double CARBON = 12.011;
int main()
{
/* Declare variables. */
/* Exit program. */
return 0;
}
/*——————————————————————–*/
const double CARBON = 12.011;
const double NITROGEN = 14.00674;
const double HYDROGEN = 1.00794;
const double SULFUR = 32.066;
int main()
{
cin >> no_nitro;
cout << “Enter the number of sulfur atoms. \n”;
cin >> no_sulfur;
cout << “Enter the number of hydrogen atoms. \n”;
cin >> no_hydro;
/* Problem chapter2_40 */
/* */
/* This program computes the average atomic weight of the atoms */
/* found in a particular amino acid given the number of atoms for */
/* each of the five elements found in amino acid. */
int no_oxy, no_carbon, no_nitro, no_hydro, no_sulfur, total_no;
double average_atomic_weight;
/* Enter the number of atoms for each of the five elements. */
cout << “Enter the number of oxygen atoms found “
<< ” in the amino acid. \n”;
cin >> no_oxy;
average_atomic_weight = ((no_oxy*OXYGEN) + (no_carbon*CARBON) +
(no_nitro*NITROGEN) + (no_sulfur*SULFUR) +
(no_hydro*HYDROGEN))/total_no;
/* Print the average atomic weight. */
cout << “The average weight of the atoms in this particular amino “
<< “acid is ” << average_atomic_weight << endl;
}
using namespace std;
int main()
{
/* Declare variables. */
double x, answer;
}
/*——————————————————————–*/
/*——————————————————————–*/
/* Problem chapter2_42 */
/* */
/* This program reads in a positive number and then computes */
/* the logarithm of that value to the base 8. */
#include <iostream>