# Solutions for selected sample questions:

Solutions are NOT unique!
## SAMPLE FINAL VAR 1 : Circle

/* SAMPLE FINAL 1 VAR
(a) Input the radius of a circle using fscanf();
(b) Write one function to calculate the area (pi*r*r) and circumference (2*pi*r) of the circle
(note that you will need to use pointers in the function (if you don't use records)).
(3) print using fprintf() the radius, area and circumferance
(NOTE: This is not good programming style)
*/

Solutions:

[Using Pointers, One Function (grade=100%)]

[Using Records, One Function (grade=100%)]

[Good Programming Style, Using Two (2) functions (grade=75%)]
## SAMPLE FINAL FLOW 1 : Biggest and Smallest

/* SAMPLE FINAL 2 FLOW Write a program that
(1) Prompt the user and read four positive integers (fixed-point);
(2) Call a function big() to return the largest integer.
(3) Call a function small() to return the smallest integer
(4) Print the largest and smallest integers using fprintf()
*/

Solutions:

[Direct Approach, No Functions Used (grade=75%)]

[Two Functions Used (grade=100%)]

[Calling One Function from main() using Pointers (NOT GOOD STYLE) (grade=75%)]

[Using Records, Calling One Function from main() (grade=85%)]
## SAMPLE FINAL ARRAY 1 : Biggest and its Index

/* SAMPLE FINAL 3 ARRAY Write a program that
(1) reads 6 positive integers into an array b[]
(2) call a function big() to return the index of the array which
contains the largest integer
(3) Print the index of the array and value stored at this location.
*/

Solution
## SAMPLE FINAL RECORD 2 : Circle

/* SAMPLE FINAL 4 RECORD (Based on SAMPLE FINAL 1 VAR)
(a) Define a record to hold the radius, area, and circumference of a circle.
(a) Input the radius of a circle using fscanf();
(b) Write one function to calculate the area (pi*r*r) and circumference (2*pi*r) of the circle.
(3) print using fprintf() the radius, area and circumferance
*/

Solution

To report errors or broken links, contact Bai Xiao Ming (Jonathon White) @ xiaomingbai AT gmail.com