# Resulthastobebetween0and5inclusive 1rand6

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

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

## This note was uploaded on 01/12/2010 for the course CS CS 201 taught by Professor Dr.naveedmalik during the Spring '09 term at Virtual University of Pakistan.

Ask a homework question - tutors are online