exercise 1.35 solution

#include <iostream>

using std::cout;
using std::endl;

int main() {
        cout << static_cast<int>('A') << endl;
        cout << static_cast<int>('B') << endl;
        cout << static_cast<int>('C') << endl;
        cout << static_cast<int>('a') << endl;
        cout << static_cast<int>('b') << endl;
        cout << static_cast<int>('c') << endl;
        cout << static_cast<int>('0') << endl;
        cout << static_cast<int>('1') << endl;

        return 0;
}
Advertisements

exercise 1.32 solution

#include <iostream>

using std::cout;
using std::endl;
using std::cin;

int main() {
        int number1, number2;

        cout << "Enter first number: ";
        cin >> number1;

        cout << endl << "Enter second number: ";
        cin >> number2;

        if(number1 % number2 == 0) {
                cout << number1 << " is multiple of " << number2 << endl;
        }else{
                cout << number1 << " is not multiple of " << number2 << endl;
        }

        return 0;
}

exercise 1.30 solution

#include <iostream>

using std::cout;
using std::endl;
using std::cin;

int main() {
	int num1, num2, num3, num4, num5;

	cout << "Enter first integer: ";
	cin >> num1;

	cout << "\nEnter second integer: ";
	cin >> num2;

	cout << "\nEnter third integer: ";
	cin >> num3;

	cout << "\nEnter fourth integer: ";
	cin >> num4;

	cout << "\nEnter fifth integer: ";
	cin >> num5;

	int largest_num = num1;
	if(largest_num < num2) {
		largest_num = num2;
	}

	if(largest_num < num3) {
		largest_num = num3;
	}

	if(largest_num < num4) {
		largest_num = num4;
	}

	if(largest_num < num5) {
		largest_num = num5;
	}

	cout << "\nlargest number " << largest_num;

	int smallest_num = num1;
	if(smallest_num > num2) {
		smallest_num = num2;
	}

	if(smallest_num > num3) {
		smallest_num = num3;
	}

	if(smallest_num > num4) {
		smallest_num = num4;
	}

	if(smallest_num > num5) {
		smallest_num = num5;
	}

	cout << "\nsmallest number " << smallest_num << endl;

	return 0;
}

exericse 1.28 solution

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main() {
	cout << "*********" << "\t" << "   ***   " << "    *    " << "    *    " << endl;
	cout << "*       *" << "\t" << " *     * " << "   ***   " << "   * *   " << endl;
	cout << "*       *" << "\t" << "*       *" << "  *****  " << "  *   *  " << endl;
	cout << "*       *" << "\t" << "*       *" << "    *    " << " *     * " << endl;
	cout << "*       *" << "\t" << "*       *" << "    *    " << "*       *" << endl;
	cout << "*       *" << "\t" << "*       *" << "    *    " << " *     * " << endl;
	cout << "*       *" << "\t" << "*       *" << "    *    " << "  *   *  " << endl;
	cout << "*       *" << "\t" << " *     * " << "    *    " << "   * *   " << endl;
	cout << "*********" << "\t" << "   ***   " << "    *    " << "    *    " << endl;

	return 0;
}