C programming

Mary PW Chin 钱碧慧博士
PhD (Wales), MSc (Surrey)
E-mail:
Synopsis
  1. The 'printf' function;
  2. Compiling and running;
  3. Variables, integers and floating-point numbers;
  4. Arithmetic operators;
  5. Auto-completion (TAB key) and command history (UP and DOWN arrow keys);
  6. For loops:
  7. Sequence of numbers;
  8. Line and block commenting.
Exercise
  1. Refer to the program on slide #34. What happens if we make five changes
    • the 'n' on line #20 to 'a';
    • the 'n' on line #25 to 'b';
    • the 'n' on line #30 to 'c';
    • the 'n' on line #35 to 'd';
    • the 'n' on line #40 to 'e',
    and then run? What changes on other lines do we need in order to make the program work?
  2. Write a program that prints the following with as few fprintf functions as you can:
    
                 ******************
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 *                *
                 ******************
              
  3. Write a program that prints the following with as few fprintf() functions as you can:
                      *
                     * *
                    *   *
                   *     *
                  *       *
                 *         *
                *           *
               *             *
              *               *
               *             *
                *           *
                 *         *
                  *       *
                   *     *
                    *   *
                     * *
                      *
              
  4. Write a program that prints the following with as few fprintf() functions as you can:
               *
               **
               ***
               ****
               *****
               ******
               *******
               ********
               *********
               **********
               *********
               ********
               *******
               ******
               *****
               ****
               ***
               **
               *
              
  5. Write a program that prints the following with as few fprintf() functions as you can:
               *  *  *  *  *
                *  *  *  *  *
                 *  *  *  *  *
               *  *  *  *  *
                *  *  *  *  *
                 *  *  *  *  *
               *  *  *  *  *
                *  *  *  *  *
                 *  *  *  *  *
               *  *  *  *  *
                *  *  *  *  *
                 *  *  *  *  *
              


Python programming

1st bite of Python

Getting started

2nd bite of Python

Dice

3rd bite of Python

Circles

4th bite of Python

Statistics & histograms

5th bite of Python

More loops

6th bite of Python

Pretty nets

7th bite of Python

Jumping man

8th bite of Python

Medical scans