Lecture 12: October 21, 2019

Reading: C text, §8, 9
Due: Extra Credit #1: due October 21, 2019; Homework #2, due October 24, 2019


  1. Greetings and felicitations!
    1. General: there are a couple of aids to learning the Bourne-Again shell, bash(1)
    2. Homework 2: I posted an announcement to answer some of the questions.
    3. Extra Credit assignment, problem 2; you just need to give the command, not execute it; but you can replace “/usr” with “/home” if you like.
  2. Operators
    1. Comma operator ,; use while(printf("> "), scanf("%d", &x) != EOF) and y = 3; x = y++, 20
    2. Order of evaluation of function arguments; use i = 10; f(i, ++i) and f(i, i++)
  3. C characters
    1. Characters as integers and numbers (caesar-enc.c, caesar-dec.c)
  4. String library functions
    1. Prototypes in include file string.h
    2. String length: strlen(str)
    3. String copy: strcpy(dest, src); strncpy(dest, src, number_chars)
    4. String catenation: strcat(dest, src); strncat(dest, src, number_chars)
    5. String comparison: strcmp(dest, src); strncmp(dest, src, number_chars)
  5. Recursive greatest common divisor
    1. Go through Euclidean algorithm for computing gcd
    2. Walk through function gcd, with m = 4 and n = 6
    3. Do it again with m = 126 and n = 28
    4. Go through program gcd.c

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 36A, Programming and Problem Solving
Version of October 21, 2019 at 6:04PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh