Resulthastobebetween0and5inclusive 1rand6

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0 ] ; for ( i = 0 ; i < 100 ; i ++ ) { a [ i ] = i ; } cout << “ Please enter a positive integer “ ; cin >> z ; int found = 0 ; Example 5 Example 5 for ( i =0 ; i < 100 ; i ++ ) { if ( z == a [ i ] ) { found = 1 ; break ; } } Example 5 if ( found == 1 ) cout << “ We found the integer at position ” << i ; else cout << “ The number was not found” ; rand ( ) # include < stdlib.h > 0 ­ 32767 Calling rand ( ) x = rand ( ) ; A call goes to ” rand ( ) “ , it generates a number and returns to x Modulus “ % ” It returns the remainder rand ( ) % 6 = ? Result has to be between 0 and 5 inclusive 1 + rand ( ) % 6 It will randomly generate number betw...
View Full Document

Ask a homework question - tutors are online