Macro - PowerPoint PPT Presentation

1 / 23
About This Presentation
Title:

Macro

Description:

Macro – PowerPoint PPT presentation

Number of Views:57
Avg rating:3.0/5.0
Slides: 24
Provided by: Gala68
Category:
Tags: macro | void

less

Transcript and Presenter's Notes

Title: Macro


1
TCS 1011 Tutorial 4 Week IV
2
Pointer
char str "Hello" str coutltltstrltltendl
char str "Hello" coutltltstrltltendl
Output ello
Output hello
int i int n 10 i n i cout ltlt n
ltlt n ltltendl
int i int n 10 i n cout ltlt i ltlt
endl cout ltlt i ltlt endl cout ltlt i ltlt endl
n 11
3
Question 1
4
ASCII Table
97 65 32
Source http//www.lookuptables.com/
5
Recursive
In Memory Representation
Pointer p
6
Recursive
In Memory Representation
Pointer p
7
Recursive
In Memory Representation
Pointer p
8
Recursive
In Memory Representation
Pointer p
9
Simplify Part 1
10
Simplify Part 2
11
General Form of Recursive
Pseudo-Code
return-type function_name(argument_list)
condition(s) to quit/return do the
operation(s) need call itself again
12
Question 2
13
Length( ) --- 1st Run
In Memory Representation
Code
int length(char p) if (p '\0')
return 0 else return 1 length(p1)
Pointer p
14
Length( ) --- 2nd Run
In Memory Representation
Code
int length(char p) if (p '\0')
return 0 else return 1 length(p1)
Pointer p
15
Length( ) --- 3rd Run
In Memory Representation
Code
int length(char p) if (p '\0')
return 0 else return 1 length(p1)
Pointer p
16
Length( ) --- 4th Run
In Memory Representation
Code
int length(char p) if (p '\0')
return 0 else return 1 length(p1)
Pointer p
17
Recursive Length of String
Length( )
18
Question 3
19
Recursive - Sum
  • Sum(100) 100 Sum(99)
  • Sum(99) 99 Sum(98)
  • Sum(98) 98 Sum(97)
  • ..
  • Sum(1) 1

General Form ? Sum(n) n Sum(n 1)
Condition to stop ? Sum(1) 1, means, where n
1 for Sum(n)
20
Question 5
21
Palindrome Case 1
22
Palindrome Case 2
23
Q A
http//wfooi.blogspot.com wfooi_at_mmu.edu.my 03-8312
5477
Write a Comment
User Comments (0)
About PowerShow.com