Showing posts with label tutorial. Show all posts
Showing posts with label tutorial. Show all posts

9/12/09

NUMBER PATTERNS AND SEQUENCES TUTORIAL

NUMBER PATTERNS AND SEQUENCES TUTORIAL

Subject : Mathematics Form 1




and To get the document in MS word file


=
View


To Get more DOWNLOAD 






IN WORD DOCS

 or see it on gooogle doc





Learning Objective : Number Patterns and Number Sequences Learning Outcomes : 1. Identify patterns of number sequences. 2. Extend, complete and construct number sequences. 3. Recognize odd and even numbers and explore their general properties. 4. Identify prime numbers. 5. Understand factors and prime factors. 6. Find the common factors and highest common factors (HCF). 7. Understand multiples. 8. Find the common multiples and lowest common multiples (LCM

2.1 Number Patterns & Number Sequences - A list of numbers that follow a certain pattern is called number sequence. - In a number sequence, we can see how the number pattern is form.


To see the lesson in MS word form
DOWNLOAD hERE
1. 3, 7, 11, 15, 19 Pattern : begin with 3 and add 4 to the number before it (+4) 2. 305, 300, 295, 290, 285 Pattern : begin with 305 then minus / subtract 5 from the number before it (- 5) 3. 2, 6, 18, 54, 162 Pattern : begin with 2, then multiply each number by 3 (x3) 4. 64, 32, 16, 8, 4 Pattern : begin with 64 then divide each number by 2 (÷ 2)


Complete the missing number in the n
List the number sequences for these number sequences 1. 3, 6, 9 , 12, 15 , 18 Pattern : + 3 2. 64, 56, 48, 40, 32, 29 Pattern : - 8 3. 7, 21, 63, 189, 567, 1761 Pattern : x 3 4. 800, 400, 200, 100, 50, 25 Pattern : ÷ 2

umber patterns
1. List down the whole numbers between 30 to 37 31, 32, 33, 34, 35, 36 2. Add 5 to whole numbers from 3 to 28 3, 8, 13, 18, 23, 28 3. Subtract 3 from whole number from 13 to 1 13, 10, 7, 4, 1 4. Multiply 4 to whole numbers from 2 to 128 2, 8, 32, 128


2.2 Even Numbers & Odd Numbers
- Even numbers are whole numbers that can be divided by 2 exactly (no remainder). Example: 2, 4, 6, 8, 10, … - Odd numbers are whole numbers that cannot be divided by 2 exactly (has remainder). Example: 1, 3, 5, 7, 9, 11, … - ‘0’ is neither an add number nor an even number Determine whether these numbers are even numbers or odd numbers 1. 214 214 ÷ 2 = 107 therefore 214 is an even number 2. 735 735 ÷ 2 = 367 remainder 1 therefore 735 is an odd number 3. 2 579 2 579 ÷ 2 = 1 289 remainder 1 therefore 2 579 is an odd number 4. 5 550 5 550 ÷ 2 = 2 775



2.3 Prime Numbers
- Prime number is a whole number that can only be divided by itself and number 1 - The number 1 is not a prime number because it can only be divided by itself - All the prime numbers are odd numbers except for 2 - Example : 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, … Determine whether this number is a prime number or not 1. 31 31 ÷ 1 = 31 31÷ 31 = 1 31 can only be divided by 1 and itself. 31 is a prime number 2. 65 65 ÷ 1 = 65 65 ÷ 65 = 1 65 ÷ 5 = 13 65 can be divided by 1, itself and also 5. 65 is not a prime number 3. 71 71 ÷ 1 = 71 71÷ 71 = 1 71 can only be divided by 1 and itself. 71 is a prime number 4. 93 93 ÷ 1 = 93 93 ÷ 93 = 1 93 ÷ 3 = 31 93 can be divided by 1, itself and 3. 93 is not a prime number


Sieve Of Erastosthenes - A method of finding prime numbers between 1 to 100 (25 numbers) Step 1: list down all whole numbers between 1 to 100

  Whole numbers photo

Step 2: Cross out 1, because 1 is not a prime number. Step 3: Circle 2 and cross out all numbers that can divided by 2. Step 4: Circle 3 and cross out all numbers that can divided by 3. Step 5: Circle 5 and cross out all numbers that can divided by 5. Step 6: Circle 7 and cross out all numbers that can divided by 7. Step 7: Circle all remaining numbers and list down. The remaining numbers are the prime numbers between 1 to 100. Answer: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.

2.4 Factors
- A factor of a given number is the number that can divide the given number exactly without any remainder. - The number 1 is a factor of all numbers. - Every number is a factor of itself - A whole number may have more than 2 factors. List all the factors of these numbers 1. 6 1 x 6 factors of 6 = 1, 2, 3, 6 2 x 3 2. 18 1 x 18 factors of 6 = 1, 2, 3, 6, 9, 18 2 x 9 3 x 6 3. 45 1 x 45 factors of 6 = 1, 3, 5, 9, 15, 45 3 x 15 5 x 9 4. 88 1 x 88 factors of 6 = 1, 2, 4, 8, 11, 22, 44, 88 2 x 44 4 x 22 8 x 11 Determine whether 1. 9 is a factor of 54 54 ÷ 9 = 6 (exact division, no remainder) Therefore 9 is a factor of 54 2. 7 is a factor of 48 48 ÷ 7 = 6 remainder 6 (not exact division) Therefore 7 is not a factor of 48


2.5 Prime Factors
- Prime factors of a given number are factors which are also prime numbers. - Example: Factors of 6: 1, 2, 3, 6 Prime numbers: 2 and 3 Prime factors of 6: 2 and 3 List all the prime factors of these numbers. 1. 24 Method 1 : List the factors Factors of 24 : 1, 2, 3, 4, 6, 8, 12, 24 Prime Factors : 2 and 3


Method 2 : Continuous Division




Determine whether
1. 2 is a prime factor of 18 18 ÷ 2 = 9 (exact division, no remainder) Therefore 2 is a prime factor of 18 2. 7 is a factor of 46 46 ÷ 7 = 6 remainder 4 (not exact division) Therefore 7 is not a prime factor of 46 3. 4 is a factor of 200 200 ÷ 4 = 50 (exact division, no remainder) 4 is a factor of 200 but 4 is not a prime number Therefore 4 is not a prime factor of 200


.6 Common Factors & Highest Common Factors (HCF)

Common Factors - Common factor is a number that is a factor of two or more numbers. - 1 is a common factor of all numbers. Find all the common factors of these numbers. 1. 8 and 12 Factors of 8 : 1, 2, 4, 8 Factors of 12 : 1, 2, 3, 4, 6, 12 Common factors of 8 and 12 : 1, 2, 4 2. 6, 12 and 18 Factors of 6 : 1, 2, 3, 6 Factors of 12 : 1, 2, 3, 4, 6, 12 Factors of 18 : 1, 2, 3, 6, 9, 18 Common factors of 6, 12 and 18: 1, 2, 3, 6 3. 27, 36 and 81 Factors of 27 : 1, 3, 9, 27 Factors of 36 : 1, 2, 3, 4, 6, 9, 12, 18, 36 Factors of 81 : 1, 3, 9, 27, 81 4. Common factors of 27, 36 and 81: 1, 3, 9 Determine whether 1. 6 is a common factor of 12, 18 and 24 12 ÷ 6 = 2 (exact division, no remainder) 18 ÷ 6 = 3 (exact division, no remainder) 24 ÷ 6 = 4 (exact division, no remainder) Therefore 6 is a common factor of 12, 18 and 24 2. 9 is a common factor of 63 and 120 63 ÷ 9 = 7 (exact division, no remainder) 120 ÷ 9 = 13 remainder 3 (not exact division) Therefore 9 is a not common factor of 63 and 120
Highest Common Factors ( HCF )
-
HCF of two or more numbers is the largest common factor of these numbers.




2.7 Multiples
- The multiples of a number is the product of that number with any whole number except
zero.
- Multiples are also a sequence.

List the first five multiples of these numbers.
1. 3
3 x 1 = 3
3 x 2 = 6
3 x 3 = 9
3 x 4 = 12
3 x 5 = 15
The first five multiples of 3 are 3, 6, 9, 12 and 15

2. 9
9 x 1 = 9
9 x 2 = 18
9 x 3 = 27
9 x 4 = 36
9 x 5 = 45
The first five multiples of 3 are 9, 18, 27, and 45


List all the multiples of these numbers.
1. Multiples of 2 between 13 to 27
14, 16, 18, 20, 22, 24, 26

2. Multiples of 5 from 50 to 70
50, 55, 60, 65, 70

Determine whether
1. 48 is a multiple of 4
48 ÷ 4 = 12 (exact division, no remainder)
Therefore 48 is a multiple of 4

2. 26 is a multiple of 3
26 ÷ 3 = 3 remainder 2 (not an exact division, has remainder)
Therefore 26 is not a multiple of 3


2.6 Common Multiples & Lowest Common Multiples (LCM)

Common Multiples
- Common multiple is a number that is a multiple of two or more numbers.
- Example 8 is a common multiple of 2 and 4
Multiple of 2 : 2, 4, 6, 8, 10, 12 ,… ( 8 is multiple of 2 )
Multiple of 4 : 4, 8, 12, 16, 20, … ( 8 is multiple of 4 )
Therefore 8 is a common multiple of 2 and 4

Find the first three common multiples of these numbers.
1. 2 and 3
Multiple of 2 : 2, 4, 6, 8, 10, 12 , 14, 16, 18, 20, …
Multiple of 3 : 3, 6, 9, 12, 15, 18, 21, 24, …
Therefore the first three common multiples of 2 and 3 are 6, 12, and 18


2. 3, 4 and 6
Multiple of 3 : 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36,..
Multiple of 4 : 4, 8, 12, 16, 20, 24, 28, 32, 36, ..
Multiple of 6 : 6, 12, 18, 24, 30, 36, ..
Therefore the first three common multiples of 3, 4 and 6 are 12, 24 and 36

Determine whether
1. 50 is a common multiple of 2 and 5
50 ÷ 2 = 25 (exact division, no remainder)
50 ÷ 5 = 10 (exact division, no remainder)
Therefore 50 is a common multiple of 2 and 5

2. 120 is a common multiple of 3, 4 and 9
120 ÷3 = 40 (exact division, no remainder)
120 ÷4 =30 (exact division, no remainder)
120 ÷ 9 = 13 remainder 3 (not exact division)
Therefore 120 is not a common multiple of 3, 4 and 9
\

http://www.4shared.com/file/125589473/1f7766d0/math_tests__School_exams_e.html


Lowest Common Multiples ( LCM )
- LCM of two or more numbers is the smallest common multiple of these numbers.

Find the LCM of the followings.
1. 6 and 36
Method 1 : Listing the multiples
Multiple of 6 : 6, 12, 18, 24, 30, 36, .
Multiple of 9 : 9, 18, 27, 36, …
The LCM of 6 and 9 is 18

and a math test   https://docs.google.com/math exercises
whole number lesson






Please leave your comments and notices here below

3/18/09

Visual c++ IntersectRect example tutorial




In this visual c++ IntersectRect Example we will learn how to use the mfc intersection function


The intersected rectangle hatched in Red

to get the exefile click here and download the file and get the complete project and thinks of additions you can make



To start


1- Start a new project and let us name it IntersectRectangle

2- chose single document and deselect printing and print view no need for them

3- Add the following members to the view class

public:

BOOL m_b_IsIntersected; // weather there is intersection or not

CRect m_Gray_Rectangle , m_Moving_Rectangle ,m_RectIntersection ;

// constant REct and moving and the rectangle of intersection

make your data members public to avoid using getters and setters

4-Initilize the values of the two rectangles in the constructor as follows


CIntersectrectangleView::CIntersectrectangleView():m_Moving_Rectangle(100,60,160,120),m_Gray_Rectangle(90,80,120,110),m_b_IsIntersected(FALSE)

5-

Add the following messege handler to the derived view class


WM_TIMER ,WM_LBUTONDOWN, WM_RBUTTONDOWN

and edit them as follows

start with Wm timer


void CIntersectrectangleView::OnTimer(UINT nIDEvent) {

if(m_Moving_Rectangle.right> 300) m_Moving_Rectangle.OffsetRect(-280,0) ;

m_Moving_Rectangle.OffsetRect(20,0);InvalidateRect(NULL,TRUE); CView::OnTimer(nIDEvent);}


and

void CIntersectrectangleView::OnRButtonDown(UINT nFlags, CPoint point) { KillTimer(1);



CView::OnRButtonDown(nFlags, point);}


and


void CIntersectrectangleView::OnLButtonDown(UINT nFlags, CPoint point) {

SetTimer(1, 450,NULL) ;

CView::OnLButtonDown(nFlags, point);

}


6-


edit the ondraw member functions as follows


void CIntersectrectangleView::OnDraw(CDC* pDC){






pDC->TextOut(60,13,"Press the right button to start moving the black rectangle and the right to stop it and notice the intersection");

pDC->SelectStockObject(BLACK_BRUSH);

pDC->Rectangle(m_Moving_Rectangle);

pDC->SelectStockObject(LTGRAY_BRUSH);

pDC->Rectangle(m_Gray_Rectangle);

LPRECT lp_move = m_Moving_Rectangle.operator LPRECT() ;

// cast the moving rect to LPRECT

LPRECT lp_gray = m_Gray_Rectangle.operator LPRECT() ;

// and so as to the grayrect



m_b_IsIntersected = m_RectIntersection.IntersectRect( lp_move ,lp_gray);
// find whethere there is intersection and draw the intersection rect with hatchbrush
if( m_b_IsIntersected){



CBrush brushHatch(HS_DIAGCROSS, RGB(255, 90, 0));

pDC->SelectObject(brushHatch) ;

pDC->Rectangle(m_RectIntersection);
//I used getstockobject because it is easier to use

}

8- finally build the application and see how it works





Do not forget to use casting when using intersictRect it only accept arguments of type LPRECT

for more example see the rest of the blog


I hope that you enjoyed this tutorial









}



1/28/09

Microsoft Visual c++ Timer Example

In This Tutorial microsoft visual c++ Timer example we use left mouse buttons to trigger the motion of a rectangle and kill the motion of a rectangle m_rect_time when left button up










=

note the photos here are protected by copyright rules


DOWNLOADS

The downloadds contain the whole project plus the Exe in the debug folder
To start rect motion presss left mouse button and stop it press right mouse button click


and start again using the left mouse the time was chosen is 300 milli seconds



To start the tutorial



1- Start new single document application and let us name it TimeEX and deselect printing and print proview



2- In your derived view class add the following public data member m_rect_time ;

3- In your view class initilise it as follows :m_rect_time( 20,20,50,50) .

4- Add windows messege handlers for WM_TIMER , WM_RBUTTONDOWN, WM_LBUTTOMDOWN .

5- Edit the OnTimer function as shown in red
// timer action


void CTimerEXView::OnTimer(UINT nIDEvent) {

if(m_rect_time.right> 250 ) m_rect_time.OffsetRect( -250,0) ;



// rectangle motion


m_rect_time.OffsetRect( 50,0) ;

InvalidateRect(NULL,TRUE);





CView::OnTimer(nIDEvent);


}



6-Edit on left button handler as shown here in red

SetTimer(1, 300,NULL) ; // 3 00 millisecond

// trigger the timer by setting the time
3 00 millisecond 1 mearns first timer NULL timers window


7- Edit the on right buttom down as folows



KillTimer(1);

// we have only one timer


8-Edit the ondRaw as follows





pDC->TextOut(70 ,70,"Press the left mouse button to start moving the rectangle using timer and right button to stop it") ;

pDC->SelectStockObject(BLACK_BRUSH );

pDC->Rectangle(m_rect_time) ;



9- Build the application and start stoping the rectangle as what I did here is the figure below






of course you can use bigger font for the text and can change tiime interval by change the value in settimer second paprameter

Press CTrl F5 abd build it


to download the whole project click here
I hope that I guided how to create simple timer tutorial

Hints To practice
if you want multiple timers then is what you have to do is to trigger multiple timer by the function settimer by changing the first and second parameter
for example if you have second timer SetTimer( 2,400, NULL)
second one is set to 400 and add handler to killtimer by killTimer(2) ;
and so on also try different values in the second parameters in settimer ( ) and see the effects


Use callBack functions instead of the WM_TIMER you used and try to control the clock by increasing and decreasing time intervals using menus
for lessons ans extra tutorials see the rest of the blog

for notes and and comments leave me a post below

Creating Dual Timers

1 Create buttons in the toolbar as shown in the figure below


Make like them
Then assign the following ids for the buttons

IDC_GO_LEFT , IDC_BAN_HORIZONTAL_MOVES ,IDC_ACTIVATE_VERTICAL_MOVES AND IDC_FREESE_UPDOWN

2- In the view class add the following member variables
BOOL m_b_halt_leftright,m_Bol_suspended_UpDown_motion
;
CRect m_animated_sqaure ;

Make them public
The Boolean variables are used to enable moving and the square is the animated object

3-Go to the constructor of the class and edit it as follows

CDualtimersView::CDualtimersView():m_animated_sqaure(20,20,50,50)
{

m_b_halt_leftright = TRUE ;

m_Bol_suspended_UpDown_motion = TRUE ;


}

// so at first the square is stopped

Now go on Draw virtual function and edit as follows

void CDualtimersView::OnDraw(CDC* pDC)
{
pDC->TextOut(40,10," Press Toolbars bottons");

pDC->SelectStockObject(BLACK_BRUSH );
pDC->Rectangle(m_animated_sqaure) ;



}

// The ondraw vertual function with dimentions 30 pixels by 30 pixels draw black square

Add windows message handler for the WM_timer and edit as

void CDualtimersView::OnTimer(UINT IDEvent)
{



switch(IDEvent)
{

case 1:

// first timer

if(m_animated_sqaure.right> 250 )
m_animated_sqaure.OffsetRect( -250,0) ;
m_animated_sqaure.OffsetRect( 20,0) ;
InvalidateRect(NULL,TRUE);


break ;
case 2:
// second timer and the action to shift
if(m_animated_sqaure.top <10)
m_animated_sqaure.OffsetRect(0,200);
m_animated_sqaure.OffsetRect( 0,-10) ;
InvalidateRect(NULL,TRUE);
break;
default:



CView::OnTimer(IDEvent);
}




}


Now add windows mesege handler for the Tolbar buttons

We start with the first button

void CDualtimersView::OnGoLeft()
{
// see if the button not pressed
if(m_b_halt_leftright) {

SetTimer( 1,500,NULL) ;
// half a second
m_b_halt_leftright =FALSE ;
}
}

and add Update windows messge handler for the same button
void CDualtimersView::OnUpdateGoLeft(CCmdUI* pCmdUI)
{
pCmdUI->Enable(m_b_halt_leftright);



}

Do the same for the whole buttons as you can see here


void CDualtimersView::OnBanHorizontalMoves()
{
if(!m_b_halt_leftright) {
KillTimer(1);
m_b_halt_leftright =TRUE ;
}

}

void CDualtimersView::OnUpdateBanHorizontalMoves(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!m_b_halt_leftright);


}

void CDualtimersView::OnActivateVerticalStep()
{
if(m_Bol_suspended_UpDown_motion) {
SetTimer( 2,200,NULL) ;
m_Bol_suspended_UpDown_motion =FALSE ;
}




}

void CDualtimersView::OnUpdateActivateVerticalStep(CCmdUI* pCmdUI)
{

pCmdUI->Enable(m_Bol_suspended_UpDown_motion);


}

void CDualtimersView::OnFreezeUpdown()
{


if(!m_Bol_suspended_UpDown_motion) {
KillTimer(2);
m_Bol_suspended_UpDown_motion =TRUE ;
}


}

void CDualtimersView::OnUpdateFreezeUpdown(CCmdUI* pCmdUI)
{
pCmdUI->Enable(!m_Bol_suspended_UpDown_motion);


}

As an activity Add discription to the code i did
Note use better method for naming
and also see the toolbar example for more on toolbars and use menu items to start and stop the motion and add keyboard accelerators


Click here to download both examples Download link

Please leave your feedback below