Skip to main content

Self Check

Self check questions are short review questions about the content of the chapter.

Short Answers

  1. How many different values can be stored using 8 bits?
  2. What are the similarity/differences between float and double data type?
  3. What is the best data type to store each of the values below?
    • The number of people living in Canada
    • pi to 2 decimal places
    • The answer to a multiple choice question where the choices are A,B,C or D
    • pi to 10 decimal places
    • Number of muffins sold
    • Taxes due on a bottle of pop
    • The number of people living in the entire world
  4. What does mantissa mean? Provide an example to illustrate your answer?

Programming Problems

  1. Write a program that will write out the following, note that all indentations are tabs.

    The itsy bitsy spider crawled up the water spout
    down came the rain to wash the spider out
    then came the sun that dried up all the rain
    and the itsy bitsy spider crawled up the spout again
  2. Write a program that will write out the following to the screen.

    In DOS based systems, you use \ in your path
    In UNIX based systems you use / in your path
    99% of students polled love ice-cream!
    "Always be wary of any helpful item that weighs less than its operating manual."
    - Terry Pratchett
  3. Re-write the hello world program so that it will make a "beep" sounds just before it ends

  4. Write a program that will ask the user to enter a decimal number. It will then print out the part of the number before the decimal point and after the decimal point separately. You may assume there will be no more than 9 digits before or after the the decimal point.

    For example, suppose the user enters 123.456. The program will print out the part before the decimal is 123 the part after the decimal is 456

    Sample run:

    Please enter a decimal number: 123.456
    the part before the decimal is 123
    the part after the decimal is 456
warning

A sample run is used to provide insight on what you should see when your program runs. You should use it as a guide to clarify the problem. However, you should never make your program work only to the example data (in this case 123.456). In other words, your program is considered correct if the user entered 123.456 and it captured 123 and 456. However, it also needs to work if they entered 987.65432 and it captures 987 and 65432. Programs are not written to only work with precisely one set of values.


The solutions for these problems are on the next page.

BEFORE you look at the solution make sure you have completed your attempt athe problems!

Programming is like many things in this world. To become good at it you must do it. Not watch others do it. Not reading through solutions. YOU need to do it yourself. Working through your solution is key. All that typing will help you remember how to do something. Do not look at this page until you have written your own solutions, compiled it and tested it. If you got some of it wrong, or if you are stuck, you can look here. If you are done and just want to verify your answer, you can look here. However, do not look here until you have actually attempted the problem.

Note that with programming, there are often more than one solutions. While the solutions here will solve the problem, it does not mean that your solution is wrong. Do not worry if your solution is not exactly the same as my solution. That will happen... the question is does your solution accomplish the task. If it does and its different.. then it is just different. It isn't wrong.