Scaling a random number as an integer value between 1 and N is accomplished using the expression ____.

A. 1 + (int)rand() / N
B. 1 + (int)rand() % N
C. (int)rand() / N
D. (int)rand() % N


Answer: B

Computer Science & Information Technology

You might also like to view...

For the network shown in Figures 3.3(a) and 3.3(b), estimate the degree correlations. Make your observation on the degree correlations for the two networks.

What will be an ideal response?

Computer Science & Information Technology

What does the FBI define as any "premeditated, politically motivated attack against information, computer systems, computer programs, and data which results in violence against non-combatant targets by sub-national groups or clandestine agents?"

A. information warfare B. cyberware C. cyberterrorism D. eTerrorism

Computer Science & Information Technology

Match the following data type conversions to their restriction

I. Text to Currency II. Number to Yes/No III. Text to AutoNumber IV. Text to Hyperlink V. Number to Hyperlink A. Not allowed when field is part of a relationship B. Zero or Null converts to No C. Converts valid address D. Must consist of numbers and valid separators E. Not allowed if field serves as primary key

Computer Science & Information Technology

?At the beginning of the twenty-first century, many firms that used only two digits to represent the year were faced with a major problem called the _____.

A. ?Y2K issue B. ?H2R issue C. ?2D issue D. ??2DGT issue

Computer Science & Information Technology