Materials
Setting up Borland C++ 5.5 Command Line Compiler and TextPad
How to produce hard copy of a C program output?
Using the Borland 5.5 Compiler and command-line tools
TextPad Tips for Borland C++ Command Line Tools and Turbo Debugger
Files
bcc55.bat - Batch file to run C programs from TextPad editor.
file-coins.c - Test C program.
We will discuss problems from the Assignment #1
as well as usage of different compilers (Turbo C and Borland C) to compile C programs.
Tutorial 3 will be devoted to solutions of the Assignment #1
and problems from the Assignment #2.
Assignment #1 Solutions
You can pick up your Assignment#1 in the room ITB/101 starting from Thursday 10:00 a.m.
Suggestions for the Assignment #2:
Problem 1
You can use the expression (int)(NUMBER+0.5) to round a real NUMBER to the nearest integer..
Problem 2
Suggestions for the Assignment #3:
Problem 3
You can use the array of strings:
Suggestions for the Assignment #3:
Problem 1
A function that prints a string of characters in standard set notation should produce the output {b,c,d,a} for the string "bcda". Probably it is good idea to print characters in the ascending order {a,b,c,d}. First, you need to check whether a set is valid ("abc" is valid, but "bcca" is not). Function EMPTY should check whether a string contains at least one character (""={} is empty, but "a"={a} is not) and return 1 if it is empty and zero otherwise (or vice versa). Function EQUAL compares two strings ("abc" is equal to "bca" as in standard set notation it is the same set {a,b,c}). UNION returns the union of two strings (UNION("k#c","cfd")={k,#,c,f,d}). SUBSET checks whether one string is subset of another ("Ab"={A,b} is subset of "kAlMb"). MEMBER function should check whether a character is member of a set ('a' is member of "bca" set).
Suggestions for the Assignment #3:
Problem 5
You can use pointer to a function to pass trigonometric or polynomial function as an argument for your MAX() function: float MAX(float (*f_trig)(float), int n, int m, ...). Alternatively, you can pass a number (f=1, 2, 3, 4) to the function MAX(int f, int n, int m,...) which denotes a mathematical function you want to use. In this case mathematical function can be implemented as switch() operator (case 1: y=x^3-x; case 2: y=sin(x);...). If pointers to functions were not covered at lectures by now, you can use the second method.
© 2002, Oleksandr Romanko