Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4.2 TrustPilot
logo-home
Examen

PSU CMPSC 101 FINAL QUESTIONS & ANSWERS 100% CORRECT!!

Note
-
Vendu
-
Pages
22
Grade
A+
Publié le
26-02-2025
Écrit en
2024/2025

branching - ANSWERdirects a program to execute either one statement group or another, depending on an expression's value. Ex; print "Too young to drive" if userAge < 16, else print "OK to drive". What is the final value of numItems? bonusVal = 5; if (bonusVal<12) numItems= 100 numItems = 200; - ANSWER5 < 12 so the first branch executes, namely numItems = 100. If userAge is greater than 62, assign 15 to discount. Else, assign 0 to discount. - ANSWERif (userAge > 62) { discount = 15; } else { discount = 0; } If numPeople is greater than 10, execute groupSize = 2 * groupSize. Otherwise, execute groupSize = 3 * groupSize and also numPeople = numPeople - 1. - ANSWERif (numPeople > 10) { groupSize = 2 * groupSize; } else { groupSize = 3 * groupSize; numPeople = numPeople - 1; } If numPlayers is greater than 11, execute teamSize = 11. Otherwise, execute teamSize = numPlayers. Then, no matter the value of numPlayers, execute teamSize = 2 * teamSize. - ANSWERif (numPlayers > 11) { teamSize = 11; } else { teamSize = numPlayers; } teamSize = 2 * teamSize; Braces - ANSWERsurrounds a branch's statements. {},sometimes redundantly called curly braces represent a grouping, such as a grouping of statements. rational operator / equality operator - ANSWERAn if-else expression commonly involves. Boolean value - ANSWEReither true or false. If userAge is 19, then userAge<25 evaluates to true. a is equal to b - ANSWERa==b a != b - ANSWERa is not equal to b or differ != - ANSWERDiffer or less than or greater than centsLost is a negative number - ANSWER< 0 is the common way to detect a negative number. Strings are equal - ANSWERif they have they have the same number of characters and corresponding characters are identical.

Montrer plus Lire moins
Établissement
PSU CMPSC 101
Cours
PSU CMPSC 101










Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

École, étude et sujet

Établissement
PSU CMPSC 101
Cours
PSU CMPSC 101

Infos sur le Document

Publié le
26 février 2025
Nombre de pages
22
Écrit en
2024/2025
Type
Examen
Contient
Questions et réponses

Sujets

Aperçu du contenu

PSU CMPSC 101 FINAL QUESTIONS &
ANSWERS 100% CORRECT!!
branching - ANSWERdirects a program to execute either one statement group or
another, depending on an expression's value.
Ex; print "Too young to drive" if userAge < 16, else print "OK to drive".

What is the final value of numItems?
bonusVal = 5;
if (bonusVal<12) numItems= 100
numItems = 200; - ANSWER5 < 12 so the first branch executes, namely numItems =
100.

If userAge is greater than 62, assign 15 to discount. Else, assign 0 to discount. -
ANSWERif (userAge > 62) {
discount = 15;
}
else {
discount = 0;
}

If numPeople is greater than 10, execute groupSize = 2 * groupSize. Otherwise,
execute groupSize = 3 * groupSize and also numPeople = numPeople - 1. -
ANSWERif (numPeople > 10) {
groupSize = 2 * groupSize;
}
else {
groupSize = 3 * groupSize;
numPeople = numPeople - 1;
}

If numPlayers is greater than 11, execute teamSize = 11. Otherwise, execute
teamSize = numPlayers. Then, no matter the value of numPlayers, execute
teamSize = 2 * teamSize. - ANSWERif (numPlayers > 11) {
teamSize = 11;
}
else {
teamSize = numPlayers;
}
teamSize = 2 * teamSize;

Braces - ANSWERsurrounds a branch's statements. {},sometimes redundantly called
curly braces represent a grouping, such as a grouping of statements.

rational operator / equality operator - ANSWERAn if-else expression commonly
involves.

,Boolean value - ANSWEReither true or false. If userAge is 19, then userAge<25
evaluates to true.

a is equal to b - ANSWERa==b

a != b - ANSWERa is not equal to b or differ

!= - ANSWERDiffer or less than or greater than

centsLost is a negative number - ANSWER< 0 is the common way to detect a
negative number.

Strings are equal - ANSWERif they have they have the same number of characters
and corresponding characters are identical.

nested if-else - ANSWERA branch's statements can include any valid statements,
including another if-else statements, such occurrence known as nested if-else
statements.

logical operator - ANSWERtreats operands as being true or false, and evaluates to
true or false.

a && b - ANSWERLogical AND: true when both of its operands are true

a || b - ANSWERLogical OR: true when at least one of its two operands are true

!false - ANSWERTRUE

! - ANSWERNOT

!a - ANSWERLogical NOT (opposite): true when its single operand is false (and false
when operand is true)

!((numPeople > 10) && (numCars > 2)) - ANSWERThe && expression is false. So !
(false) is true.

% - ANSWERmodulo (remainder

modf - ANSWERBreak into fractional and integral parts.

Iterate until c equals 'z' - ANSWERc != 'z'

bool(short for Boolean) - ANSWERdata type is for variables that store only values
true or false.

Binary operators - ANSWERThe relational operators and logical operators (except
for !) are binary operators.
Take two operands (from the left and right) and evaluate to true or false.

, bitewise - ANSWERperform AND or OR on corresponding individual bits of the
operand.

Mixing bitwise and logical operators - ANSWERx == 3 | y > 1 && z != 3
Answer= ((x == 3) || (y > 1)) && (z!= 3)

Short circuit evaluation - ANSWERskips evaluating later operands if the result of the
logical operator can already be determined.

Switch - ANSWERstatement can more clearly represent multi-branch behavior
involving a variable being compared to constant values.

case - ANSWERwhose constant comparison matches the value of the switch
expression, executes that case's statements, and then jumps to the end.

default case - ANSWERin no case matches, statements are executed

break - ANSWERstatement for a case will cause the statements within the next case
to be executed.

Boolean - ANSWERrefers to a quantity that has only two possible values, true or
false.

bool - ANSWERfor representing Boolean quantities

index - ANSWEREach string character has a position number

at() - ANSWERthe notation someString. at (0) access the character at a particular
index of a string, in this case index 0.

common error - ANSWERis to access an invalid array index, especially exactly one
larger than the largest index.

exception - ANSWERis a detected runtime error that commonly prints an error
message and terminates the program.

Good practice - ANSWERis to use .at() rather than brackets for accessing a string's
characters, due to .at()'s error checking.

conditional expression - ANSWERcondition ? exprWhenTrue : exprWhenFalse

ternary operator - ANSWERA conditional expression has three operands and thus
the "?" and ":" together are sometimes referred to.

epsilon - ANSWERThe difference threshold indicating that floating- point numbers
are equal.Epsilon's value depends on the program's expected values, but 0.0001 is
common.

loop - ANSWERis a construct that repeatedly executes specific code as long as
some condition is true
€13,56
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien


Document également disponible en groupe

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
papersbyjol West Virginia
S'abonner Vous devez être connecté afin de suivre les étudiants ou les cours
Vendu
421
Membre depuis
2 année
Nombre de followers
253
Documents
13986
Dernière vente
2 semaines de cela

3,8

72 revues

5
27
4
18
3
17
2
2
1
8

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions