Assignment 1

This assignment is due by the next learning session on Wednesday, June 13, 2012. Please complete the programs on ideone.com, and send me the links to your programs via email at martin@martinpelikan.net.

If you are having problems or questions, please email me so that we can address these before it’s too late.

Program A1:
Implement a simple program that prints out your first name, one letter at a time. That is, you will write a separate “cout” statement to print out every single letter of your name. The output should include the entire name though (you should not put end of lines after each character, the name should look intact).

Program A2:
Implement a program that reads 3 integers from the user (let’s call them i, j, and k). You may assume that the numbers are unique (each number is different from the other two numbers), and that they are all positive. Your program should then check whether any of these numbers is divisible by any other of these numbers, and report all such situations (by printing out each pair of numbers for which this holds). If none of the numbers is divisible by one of the other numbers, there are going to be no outputs.

Examples:

  1. input:
    5 10 15

    output:
    10 is divisible by 5
    15 is divisible by 5
  2. input:
    7 3 21

    output:
    21 is divisible by 7
    21 is divisible by 3
  3. input:
    13 17 3

    output:
  4. input:
    80 16 8

    output:
    80 is divisible by 16
    80 is divisible by 8
    16 is divisible by 8

Leave a Reply

Your email address will not be published. Required fields are marked *

*


× one = 5

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>