COMP 1917 Computing 1
Session 2, 2016

Tutorial - Week 4

Tutorial Presentation

Describe the ASCII coding system. (What does ASCII stand for?) Draw a schematic "map" of the ASCII Table on the board, showing (in both decimal and hexadecimal notation) where the following sets of characters lie:
  1. Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". Use void fizzbuzz(int i) to handle your printing.

  2. Write your own versions of these character functions (from the library ctype.h):
    int isdigit( int ch )
    int islower( int ch )
    int toupper( int ch )
    
    (Note: you should be able to write these functions without knowing any actual ASCII codes.)

  3. Convert from Binary to Decimal:

    10010101

  4. Convert from Decimal to Binary. Discuss subtraction and division methods:

    186

  5. Convert from Hexadecimal to Binary:

    B7A316

  6. Convert from Binary to Hexadecimal:

    1100111101010010

  7. Use Two's Complement to represent:

    -19

  8. Write a C program which scans a binary number one character at a time, computes the value of that number and prints the result in decimal format.

  9. Now modify your program so that it prompts the user to enter a base (between 2 and 10) followed by a number expressed in that base, computes the value of that number and prints the result in decimal format, e.g.
    Enter base: 7
    Enter number: 5342
    Value = 1892
    
    How would you modify your program to handle bases larger than 10?

  10. Any questions about Assignment 1.

  11. (if time permits) Write a C program which reads an integer in decimal format, from standard input, and then prints the number in binary format, one character at a time, to standard output.


Presentation Topic for Week 5

Explain Variable Scope in programming(C as an example). How can it be useful? How can it be dangerous? Some examples will be great.