COMP1511 22T1 — Programming Fundamentals _ Week 07 Laboratory Sample Solutions COMP1511 22T1 — Week 07 Laboratory Sample Solutions
Programming Fundamentals
Objectives
processing of characters and strings use of functi
...
COMP1511 22T1 — Programming Fundamentals _ Week 07 Laboratory Sample Solutions COMP1511 22T1 — Week 07 Laboratory Sample Solutions
Programming Fundamentals
Objectives
processing of characters and strings use of functions an introduction to encryption & decryption
Activities To Be Completed
The following is a list of all the activities available to complete this week... Worth one mark in total: devowel word_square string_to_lower Worth half a mark in total: caesar substitution Worth half a mark in total: decode For your interest, but not for marks: word_search You must complete all one for and two dot exercises to get full marks in the problem set for the Week. Any three dot exercises you complete will form extra bonus marks to make up for any other missing marks in the problem set component. For more details, see the course outline.
Preparation
Before the lab you should re-read the relevant lecture slides and their accompanying examples. When attempting the following exercises, make sure to read the whole exercise, including any hints and assumptions that may make the exercise easier.
೯ം೯೭ೳ೯ (●◌◌): Devowelling Text
Write a C program devowel.c which reads characters from its input and writes the same characters to its output, except it does not write lower case vowels ('a', 'e', 'i', 'o', 'u').
Your program should stop only at the end of input. For example:
5/12/22, 11:47 AM COMP1511 22T1 — Week 07 Laboratory Sample Solutions
https://cgi.cse.unsw.edu.au/~cs1511/22T1/lab/07/answers 2/22
$ ./devowel
Are you saying 'Boo' or 'Boo-Urns'?
Ar y syng 'B' r 'B-Urns'?
In this house, we obey the laws of thermodynamics!
In ths hs, w by th lws f thrmdynmcs!
Ctrl-D
HINT:
When completing this task, we suggest you do the following:
Scan in, and (maybe) print a single character at a time (you will not need a string for this question).
Write a seperate function to determine if something is a vowel.
Remember, you can use Ctrl+D to finish giving input.
Also recall that previously, when we used scanf to read characters, we always wanted a space before the %c . This allowed us to skip any whitespace (spaces, newlines, etc.) that the user typed. In this exercise, we want to read this whitespace, so we should not have a space before our %c .
When you think your program is working, you can use autotest to run some simple automated tests:
$ 1511 autotest devowel
When you are finished working on this exercise, you and your lab partner must both submit your work by running give :
$ give cs1511 lab07_devowel devowel.c
Note, even though this is a pair exercise, you both must run give from your own account before obtain the marks for this lab exercise.
Sample solution for devowel.c
You can run an automated code style checker using the following command:
$ 1511 style devowel.c
5/12/22, 11:47 AM COMP1511 22T1 — Week 07 Laboratory Sample Solutions
https://cgi.cse.unsw.edu.au/~cs1511/22T1/lab/07/answers 3/22
// Written 3/3/2018 by Andrew Taylor (
[email protected]) // read characters from stdin and write to stdout
// except lower case vowels ('a', 'e','i', 'o', 'u') are not written
#include
int is_vowel(int character);
[Show More]