DANVILLE AREA COMMUNITY COLLEGE
INTRODUCTION TO COMPUTER SCIENCE
MATH 110,     Fall 2008

Homework 1 Solutions and Grades:

Math 110

ID  hw1 hw2 exam1 hw3 hw4 exam2 hw5 hw6 exam3 hw7 hw8 exam4 final
074 19/
706 20/
550 20/
293 18/
301 19/
183 19/
534 19/
588 19/

Max 20/ 15/

// Exercise 1.23 Solution
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
   int num1, num2;  // declare variables
   cout << "Enter two integers: ";  // prompt user
   cin >> num1 >> num2;             // read values from keyboard
   // output the results
   cout << "The sum is " << num1 + num2
        << "\nThe product is " << num1 * num2
        << "\nThe difference is " << num1 - num2
        << "\nThe quotient is " << num1 / num2 << endl;
   return 0;  // indicate successful termination
}

// Exercise 1.27 Solution
// Exercise 1.27 Solution
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

int main()
{
   int radius;  // declaration
   cout << "Enter the circle radius: ";  // prompt
   cin >> radius;                        // input
   cout << "Diameter is " << radius * 2.0
        << "\nCircumference is " << 2 * 3.14159 * radius
        << "\nArea is " << 3.14159 * radius * radius << endl;
   return 0;
}

// Exercise 1.28 Solution
#include <iostream>
using std::cout;
using std::endl;

main()
{
   cout << "*********      ***         *         *\n"
        << "*       *    *     *      ***       * *\n"
        << "*       *   *       *    *****     *   *\n"
        << "*       *   *       *      *      *     *\n"
        << "*       *   *       *      *     *       *\n"
        << "*       *   *       *      *      *     *\n"
        << "*       *   *       *      *       *   *\n"
        << "*       *    *     *       *        * *\n"
        << "*********      ***         *         *" << endl;
   return 0;
}

// Exercise 1.37 Solution
#include <iostream>
using std::cout;
using std::endl;

int main()
{
   int num;
   num = 0;
   cout << "\nnumber\tsquare\tcube\n"
        << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << "\n";
   num = num + 1;
   cout << num << '\t' << num * num << '\t' << num * num * num << endl;
   return 0;
}