Chpt 7 computer science quiz questions

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Evaluate the following expression, following the rules of operator precedence: 1+ 3 * 6 / 2 - 5

5

When developing an algorithm, what tools are most useful to help you identify the goals, purpose, and logic necessary to solve a problem?

Both of these could be used based on your preference

Which of the following is a valid constant in the Math library?

Math.PI

What symbols can be used to clarify a difficult mathematical expression?

Parentheses

What is the result of the following code: i = 0; i++; i+=2; i*=2; i--;

The value in "i" will equal 5

What is the result of the following code: double myNumber = Abs(-4); myNumber = myNumber + Pow(2, 3);

The value in "myNumber" is 12

What is the result of the following code statement: int number = 12%7;

The value in "number" will equal 5

Needs to add up all the elements in an input array

findAverage()

Uses the modulus operator (%) in a while() loop until the remainder is zero

findGCD() (Greatest Common Divisor)

Uses simple series if if/else-if/else statements to identify return value

findGreatest()

Consider the code below: int answer=0; for (int i=0; i<10; i++) { answer = i; } Which statement below is an improvement on the original algorithm, replacing the entire loop and producing the same result?

int answer = 9;

You need to pick a random direction, in degrees, starting at 0 and going up to and including 360.

int randomValue = rand.Next(361);

You need to give a game player a random number of shots between 5 and 9 (inclusive).

int randomValue = rand.Next(5, 10);

You have a deck of 52 cards represented by the numbers 0 through 51. You want to pick a random card by generating a random number from 0 up to and including 51..

int randomValue = rand.Next(52);

Uses the modulus operator (%) in a for() loop and returns false if the remainder is ever zero

isPrime()

Uses several while() loops to count values and reduce a remaining amount

makeChange()

Using real division will maintain the remainder of a division operation.

true


Set pelajaran terkait

The Function of Organelles Assignment

View Set

Con Law II-Set 4 (First and Second Amendment)

View Set

Exam 5 : chps 6,7, 8, 21,36,38,14

View Set

Pediatric ati practice questions

View Set

Saunders Ch 29 41 & 52 Practice Questions

View Set

Ch. 9: Managing Groups and Teams

View Set