Wednesday, July 21, 2010

C++: A review and a small exercise

As we wrap up the basics and prepare to move on, I thought I should briefly
summarize what we've discussed so far and perhaps provide a challenge to
practice your skills.

In this saga, we have learned that a computer program is just a series of
instructions that a computer must carry out. Because computers knows their
own machine code, the source code, or human readable language code must be
translated, or compiled before we can view our results.

We've also learned that a data is used to store items, such as a characer,
decimal numbers or even true or false values. We also saw that we can output
informaiton, as well as get user input and store, then work with it using
various operators to help us with our programs. In addition, we have seen
how it is crucial to comment one's code, as well as some interesting notes
on the difference between assignment operator (=) and "is" operator (==).

So, here's the challenge: Suppose if you are working at a chemistry lab and
one of your friend, a research assistant asks you to help her with
converting temperatures from celcius to kelvin (after Lord Kelvin, a
standard way of displaying temperatures of chemicals). You ask her how she
wants it done, so your friend told you to have a program ask the user the
temperature in celcius and print the result in Kelvin. Provide; A. how you
are going to tackle this problem and a brief summary of your program in
English, then B. Write a code that uses your description to complete this
task.
Hint: You might want to use two variables (decimal ones) and a famous
operator/formula to do this task. Details of how I would do it, as well as
an example program which can be downloaded (if possible) will be posted
later. Enjoy your practice...
// JL

No comments:

Post a Comment