COIT11133, Lecture 24 - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

COIT11133, Lecture 24

Description:

Thus if the string ' cENTRAL qUeenSLand UNIversity' was passed to CapitalFirst ... Part C - writing C code (20 marks) Know your strengths. Choose the order ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 22
Provided by: david1132
Category:

less

Transcript and Presenter's Notes

Title: COIT11133, Lecture 24


1
COIT11133, Lecture 24
  • Revision

2
Overview
  • What did you learn
  • statements
  • expressions
  • variables and types
  • I/O
  • design
  • functions
  • skills
  • Study suggestions

3
Statements
switch/for
4
Examples
  • What is the output from the following C
    program?
  • include
  • using namespace std
  • void main()
  • int score 2
  • for (int i 0 i
  • score 3
  • cout

5
Examples
  • Write a program to display the following pattern.
    Your program should use at least one for loop.
  • 1 2 3 4
  • 5 6 7 8
  • 9 10 11 12

6
Variables and Types
  • declaration and initialisation
  • valid operations
  • int double float char string
  • Arrays
  • subscripts and elements
  • manipulating arrays

7
Examples
  • The syntax of the following declaration and
    initialisation is incorrect. Rewrite the
    statement with the correct syntax.
  • char Initial A

8
Expressions
  • Operators
  • arithmetic
  • relational
  • boolean
  • Expression evaluation

9
Examples
  • Simplify the following logical expression
  • !((Val 99) (Val
  • Add parentheses to the following expression to
    demonstrate explicitly the order in which the
    mathematical operations are performed
  • 1 / 3 7 4 3

10
Advanced I/O
  • Problems with cin and input of various types
  • Formatting output
  • I/O Manipulators

11
Example
  • Given the definition
  • string PlayerNameWrite a C statement to
    accept input, possibly including blanks, from the
    keyboard into the string PlayerName

12
Functions
  • What is a function?
  • Parameter passing
  • by value (copy)
  • by reference
  • Return values/types

13
Example
  • Write the definition for a function
    CapitalFirst(). CapitalFirst() accepts one
    string parameter by value and returns a string
    return value. CapitalFirst() returns a string
    that has the first letter of every word in
    capital case and every other letter, lower case.
    Thus if the string cENTRAL qUeenSLand
    UNIversity was passed to CapitalFirst() it
    would return the string Central Queensland
    University

14
Structured Design
  • Why top-down design?
  • Structure charts
  • How to design structured programs

15
Example
  • A golfer wants to buy a golf club that is between
    220 and 240 grams in weight. The golfer will
    keep inspecting the available golf clubs until a
    club of the correct weight is selected. Write a
    C program to model this process. Your program
    should ask the customer to enter the weight of
    the current club, report That club is too heavy
    if the club weighs more than 240grams or That
    club is too light if the club weighs less than
    220 grams. If a club weighs between 220 and 240
    grams, the program should report This club is
    the correct weight. The program should loop
    until a correct club is obtained. It should then
    terminate.

16
Skills
  • Creating, modifying, compiling, debugging C
    programs
  • Familiarity with a C IDE
  • Designing structure programs

17
Study Advice
  • Find out what works for you! Know yourself!
  • Exam
  • know when and where the exam is
  • know the conditions of the exam
  • Part A - quiz questions (20 marks)
  • Part B - short answer questions (20 marks)
  • Part C - writing C code (20 marks)
  • Know your strengths
  • Choose the order you do the questions
  • strengths
  • value

18
Study Advice
  • Course topic list
  • summarise all topics and what you do/don't know
  • create a timetable to cover topics
  • Practice
  • use the quizzes
  • Use the sample exam as an exam
  • Use exercises from textbook(s)

19
Study Advice
  • Have a study group
  • check your work
  • set each other problems
  • teach each other what you know
  • How to study
  • Don't leave it to the last moment
  • Give yourself free time
  • Have an appropriate study environment
  • Keep it varied

20
Study Advice
  • Preparing for the exam
  • Be familiar with the text book
  • Get a book with a good index
  • Prepare notes and "cheat sheets"
  • Be organised
  • Practice writing programs without the computer

21
Study Tute
  • Room 18/G.40
  • Wed 13th October
  • 3-5pm
  • A small amount of revision/exercises
  • Mostly what you want to cover
  • Be there at 3
Write a Comment
User Comments (0)
About PowerShow.com