C in an intro course 
Author Message
 C in an intro course

One of the courses offered at Cal Poly is a one quarter course
in C programming for students in majors other than computer
science. There is no prerequisite for this course. Almost all
the students taking this course are engineering majors.

I believe that two of the topics that should be emphasized in
this course are functions and use of libraries of functions.
So, students are called upon to write programs using functions
found, for example, in string.h and stdlib.h.

In addition I have found it useful to have a library of very
simple functions--functions that operate on integers and
arrays of integers. In this case students not only use the
library--but can also study and (easily) learn from the
implementations. Discussion of making these simple functions
"generic" (such as bsearch and qsort) is important but
beyond the scope of this note.

I thought it would be (interesting/fun/...) to see if there
is a group that would like to work to develop a common set
of files for such simple cases. I have, in order to get things
started, included a .h file below. If you are interested in
working on/observing such a project send your email address

in a file and send it to all interested parties--along with
an outline of how we might proceed.

/*+-----------------------------------------------------------------
--|     Content        :   File                        Version 1.0
--| -------------------+------------------             Date 6/6/94
--|  Specification     : spec_int.h  <---
--|  Implementation(s) : impl_int.c
--|  Test procedure(s) : test_int.c
--|
--|  Abstract : Specification of basic operations on integers
--|             and arrays of integers.
--|

  +-----------------------------------------------------------------*/

/*--------------------- SUMMARY OF FUNCTIONS -----------------------
  void put_commas (int the_int, int width);
  int  prime      (int the_int);
  int  divisors   (int the_int);
  int  random     (int the_int);

  void init_array (int A[], int high, int seed, int max, int form);
  void put_array  (int A[], int high, int cols, int width);

  int   max     (int A[], int high);
  int   min     (int A[], int high);
  float average (int A[], int high);

  int seq_search    (int A[], int high);
  int binary_search (int A[], int high);

  void select_sort (int A[], int high);
  void insert_sort (int A[], int high);
  void quicksort_1 (int A[], int high);
  void quicksort_2 (int A[], int high);
  void quicksort_3 (int A[], int high);
  void mergesort   (int A[], int high);
--------------------------------------------------------------------*/

  void put_commas (int the_int, int width);
/*
 * assumes: 0 <= the_int < 10,000,000,000
 *
 * result : the_int, including all appropriate embedded commas,
 *    is written to stdout. The value is right justified in
 *    width columns. If width is too small then width dashes
 *    are written to stdout.
 */

  int prime (int the_int);
/*
 * assumes: the_int > 0.
 *
 * result : Returns true (1) if the_int is prime; otherwise
 *    returns false (0).
 */

  int divisors (int the_int);
/*
 * assumes: the_int > 0.
 *
 * result : Returns the number of divisors of the_int.
 */

  int random (int the_int);
/*
 * result : Returns a pseudo-random number based on the value
 *    of the_int. A sequence of calls to random generates a
 *    sequence of "random" numbers.
 *
 * note_1 : Six{*filter*} bit integers are assumed.
 * note_2 : Refer to
 */

  void init_array (int A[], int high, int seed, int max);
/*
 * result : Initializes the high components of A. The values
 *    are generated by a random number generator using seed
 *    to set the value of A[0]. The kth array component is
 *    set so that 0 <= A[k] < max.
 */

  void put_array  (int A[], int high, int col, int width);
/*
 * result : The high components of A are written to stdout
 *    formatted for col columns with width digits and commas
 *    in each column.
 *
 * note_1 : Commas are embedded in the values written as
 *    described in function put_int.
 */

  int max (int A[], int high);
/*
 * result : Returns the value of A's maximum component. The array
 *    indexes are 0 ... high-1.
 */

  int min (int A[], int high);
/*
 * result : Returns the value of A's minimum component. The array
 *    indexes are 0 ... high-1.
 */

  float average (int A[], int high);
/*
 * result : Returns the average of A's components. The array
 *    indexes are 0 ... high-1.
 */

  void select_sort (int A[], int high);
/*
 * result : The components of A are sorted into ascending order.
 *
 * note_1 : The sort technique is selection sort.
 */

  void insert_sort (int A[], int high);
/*
 * result : The components of A are sorted into ascending order.
 *
 * note_1 : The sort technique is insertion sort.
 */

  void quicksort_1 (int A[], int high);
/*
 * result : The components of A are sorted into ascending order.
 *
 * note_1 : The sort technique is a simple version of quicksort.
 * note_2 : Refer to quicksort_2 and quicksort_3 for "improved"
 *    versions of quicksort. Details of the "improvements" are
 *    given as comments included with the implementations.
 */

  void quicksort_2 (int A[], int high);
/*
 * result : The components of A are sorted into ascending order.
 *
 * note_1 : The sort technique is quicksort.
 * note_2 : The implementation of quicksort_2 is an improvement
 *    of the implementation of quicksort_1.
 */

  void quicksort_3 (int A[], int high);
/*
 * result : The components of A are sorted into ascending order.
 *
 * note_1 : The sort technique is quicksort.
 * note_2 : The implementation of quicksort_3 is an improvement
 *    of the implementation of quicksort_2.
 */

  void mergesort (int A[], int high);
/*
 * result : The components of A are sorted into ascending order.
 *
 * note_1 : The sort technique is mergesort.
 */



Sat, 23 Nov 1996 06:52:23 GMT  
 C in an intro course

Thank you for this offer.  I'm interested send the necessary information



Sun, 01 Dec 1996 06:32:07 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Programming Language for Undergrad Intro CS Course?

2. Survey on using C as intro CS langauge (?)

3. Survey on using C as intro CS langa

4. C-oriented text for intro CS II

5. Intro to Linux Programming (C) courses online

6. Beta testers sought for web-based Intro to C course

7. Switching intro programming language courses

8. Needed: Good intro C course assigments

9. Looking for good textbook for CS course

10. Need C++ text for non cs major course

11. Newbie: separate big .cs file into small .cs files

12. Online course at Yahoo! Courses

 

 
Powered by phpBB® Forum Software