Link to the DIT Home Page

Dublin Institute of Technology, School of Computing
Ciarán O'Leary

  Home -> Teaching -> DT249-1 Programming and Algorithms -> Notes -> Week 08
  DT249-1 Programming and Algorithms

Week 08


Learning Outcomes:

Upon completion of this class, you should be able to:

  1. Write functions to break a large program into subsections.
  2. Write properly reusable functions.
  3. Pass arguments by value to a function.
  4. Pass arguments by reference to a function.
  5. Create automatic, static, global and register variables.
  6. Pass arrays of all dimensions to a function.
  7. Pass command line arguments to programs.
  8. Use the library functions that come with the C compiler installation.

Tasks

1. Complete the tasks from last week.

 

2. Download the code for this week's notes. Go through all the code, compiling and running each program separately. If you have any problems, ask the lab supervisor for help, or take a note of the problem and we can discuss it in next week's class.

The code is bundled into a ZIP file. This is a compressed file which contains all the separate source code files. To open this file and extract the contents, you can use the WinZip tool which is available in the lab, and is available for free download here.

Make sure to put all your code into a folder named week_7 in your programming folder on your u: drive.

 

3. Write a function to test whether an integer lies in between two boundaries. It should return true (1) or false (0).

Name the program paa_ex_08_01.c.

See sample solution here.

 

4. Write a function which takes a character as an argument by reference. It should then convert the character to uppercase, if it is lower case (use the ASCII values).

Name the program paa_ex_08_02.c.

See sample solution here.

 

5. Write a function that takes a string as an argument. It must then convert the entire string to uppercase. Use the function you wrote for step 5 above.

Name the program paa_ex_08_03.c.

See sample solution here.

 

6. Write a program which takes a variable number of command line arguments - it should then convert all the arguments to uppercase and print them out. Use the functions you created earlier.

Name the program paa_ex_08_04.c.

See sample solution here.

 

7. Write a function for the menu in your assignment. It should return the choice entered by the user.

 


Further Reading

Chapter 11 of Paul Kelly book

 

Hit Counter  [Home][School of Computing][Dublin Institute of Technology]