Lecture 2:  Problems, Algorithms, and Programs

Activity:  Programming Activity



We just saw the differences between a problem, an algorithm, and a program in the video.  We'll now use these concepts to construct a program similar to the even/odd program presented in the video.

Please solve this problem:  Is a given number divisible by 3?

In your group or as a class, come up with an algorithm or several algorithms to solve this problem.  After deciding on a single algorithm, write the necessary C code to solve the problem.  Some questions that you might need to think about include the following:  How will the number be entered?  How will you display the answer to the question above?  What numbers will you allow to be entered?

Re-write the problem formally, specifying the input and the output.

Note:  When writing the C code to solve the problem, be sure to include comments so that a reader of your code can understand how you're solving the problem.