CSC 115.005/006 Sonoma State University Spring 2022
Scribbler 2
CSC 115.005/006:
Programming I
Scribbler 2
Instructor: Henry M. Walker

Lecturer, Sonoma State University
Professor Emeritus of Computer Science and Mathematics, Grinnell College


Course Home References Course Details: Syllabus, Schedule, Deadlines, Topic organization MyroC Documentation Project Scope/
Acknowledgments

Notes:

Overview of Conditionals, Loops and Motion

The first programs in this course were simple. Each program was divided into a specified sequence of steps, and each step was completely determined.

Although these programs addressed specified tasks, the programs had very limited scope, and more complicated problems require additional processing capabilities.

Module Goals

This module explores in some detail several basic elements of problem solving with C. Through this study, students will learn how to


Example: Maze running

Consider the challenge of moving a robot through a maze. That is, the robot is placed within an environment with walls, and the robot must find a path that leads out of the maze.

One simple algorithm involves moving a robot forward. Once an obstacle is encountered, the robot turns right (until no obstacle is detected) and continues moving forward. This process of moving forward and turning right continues until the maze is left behind.

This algorithm works in some cases (such as the example at the right), but it may not be very efficient. The reader is encouraged to develop a more sophisticated algorithm that keeps track of where the robot has already been (to avoid moving in circles) and that turns right or left through openings in the middle of a long run forward.

running a maze

Example: Moving a robot along a path

Suppose a robot is to be directed to move along a path until it reaches a destination.

For this problem, the robot might take a picture of the path ahead, locate the edges of the path, and move forward, left, or right as the path continues straight or turns.


Challenges: Making decisions and repeating actions

Each of the examples (maze running and following a path) require the robot to move, based on current information about its surroundings. In moving through a maze, the robot may move forward until it encounters an obstacle, but the program cannot anticipate where the wall might be. Rather, the robot must check for an obstacle as it moves. In following a path, the robot will need to take a picture (or use its sensors), determine the current direction of the path (straight ahead, turning left or right), and move as the path proceeds.

These examples illustrate two vital needs for problem solving, beyond the capabilities illustrated in the programs of the introductory module:


Module Overview

The Getting Started module introduced sufficient elements of the C programming language and MyroC to write simple programs. However, the introductory materials could only mention basic syntax (the format of each statement) and semantics (the description of what a program statement means). With the quick introduction now completed, this module explores basic C syntax and semantics more carefully and also expands the discussion to include some additional capabilities. A brief outline follows.



created 19 April 2016 by Henry M. Walker
revised 3 July 2016 by Henry M. Walker
Valid HTML 4.01! Valid CSS!