COMP 1917 Computing 1
Session 2, 2016
Tutorial - Week 4
This page was last updated: 09/05/2016 00:18:08
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:
- non-printable characters
- digits
'0'
to '9'
- uppercase letters
'A'
to 'Z'
- lowercase letters
'a'
to 'z'
- punctuation
-
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.
-
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.)
-
Convert from Binary to Decimal:
10010101
-
Convert from Decimal to Binary. Discuss subtraction and division methods:
186
-
Convert from Hexadecimal to Binary:
B7A316
-
Convert from Binary to Hexadecimal:
1100111101010010
- Use Two's Complement to represent:
-19
-
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.
-
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?
-
Any questions about Assignment 1.
- (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.