Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

Code HS Midterm Material Questions and Answers Rated A+

Rating
-
Sold
-
Pages
6
Grade
A+
Uploaded on
09-10-2023
Written in
2023/2024

Suppose you have a function that computes the area of a diamond. Which of the following comments would be the best yo use? //This is a function // This function computes the area // Computes and returns the area of a diamond using the parameters height and width The function doesn't need a comment // Computes and returns the area of a diamond using the parameters height and width The following if statement should check that an object will fit on the screen. The variables height and width store the height and width of the object. The variables screenHeight and screenWidth store the dimensions of the screen. Which of the following pairs correctly fills in the condition for the if statement below? if(height _____ screenHeight) __ (width ___ screenWidth)){ // the object will fit completely on the screen }

Show more Read less
Institution
Course

Content preview

Code HS Midterm Material Questions
and Answers Rated A+
Suppose you have a function that computes the area of a diamond. Which of the following

comments would be the best yo use?




//This is a function

// This function computes the area

// Computes and returns the area of a diamond using the parameters height and width


The function doesn't need a comment ✔✔// Computes and returns the area of a diamond using

the parameters height and width




The following if statement should check that an object will fit on the screen. The variables height

and width store the height and width of the object. The variables screenHeight and screenWidth

store the dimensions of the screen.

Which of the following pairs correctly fills in the condition for the if statement below?

if(height _____ screenHeight) __ (width ___ screenWidth)){

// the object will fit completely on the screen

}

, (height < screenHeight) && (width < screenWidth)

(height > screenHeight) && (width > screenWidth)

(height < screenHeight) || (width < screenWidth)


(height > screenHeight) || (width < screenWidth) ✔✔(height < screenHeight) && (width <

screenWidth)




In which of the following scenarios would it be best to use a for loop?

When you need to stop looping based on input from the user

When you need to check that a user's input is valid

When you want to ask the user for 10 numbers


When you need to be able to use the block of code in many places in your program. ✔✔When

you want to ask the user for 10 numbers




In which of the following scenarios would it be best to use a while loop?

When you need to change the color of one rectangle.

When you need to get and store the user's age.

When you need to find the average of 12 numbers.


When you need to loop as long as the user inputs even numbers. ✔✔When you need to loop as

long as the user inputs even numbers.

Written for

Course

Document information

Uploaded on
October 9, 2023
Number of pages
6
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$13.69
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
dennisgathiru
5.0
(1)

Get to know the seller

Seller avatar
dennisgathiru City University New York
Follow You need to be logged in order to follow users or courses
Sold
3
Member since
2 year
Number of followers
2
Documents
2234
Last sold
7 months ago

5.0

1 reviews

5
1
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions