Definitions - A set of instructions written in a specific programming language that causes a computer to perform a specific task is referred to as COMPUTER PROGRAM. RAW FACTS are referred to as date while PROCESSED FACTS are referred to as information. A language with strict grammar rules, symbols ...
COMP 218 study questions and answers
2024
LESSON 1 -
Definitions - A set of instructions written in a specific programming language that
causes a computer to perform a specific task is referred to as COMPUTER
PROGRAM. RAW FACTS are referred to as date while PROCESSED FACTS are
referred to as information. A language with strict grammar rules, symbols and
special words used to construct a computer program is a PROGRAMMING
LANGUAGE. A step-by-step list of instruction that, when carried out, produces a
solution to a problem is referred to as ALGORITHM.
Given the algorithm in the leap year case study
Divide the year by 4 and if the remainder isn't 0Return false (The year is not a leap
year)Otherwise, divide the year by 100 and if the remainder isn't 0,Return true
(The year is a leap year)Otherwise, divide the year by 400 and if the remainder
isn't 0,Return false (The year is not a leap year)Otherwise, Return true (the year is
a leap year)
Decide whether the following years are leap years:
a. 1900
b. 2000
c. 1996
d. 1998 - a. 1900 No
b. 2000 Yes
c. 1996 Yes
d. 1998 No
,Given the algorithm from the leap year case study with the lines numbered as
follows:
1. Divide the year by 4 and if the remainder isn't 0
2. Return false (The year is not a leap year)
3. Otherwise, divide the year by 100 and if the remainder isn't 0,
4. Return true (The year is a leap year)
5. Otherwise, divide the year by 400 and if the remainder isn't 0,
6. Return false (The year is not a leap year)
7. Otherwise, Return true (the year is a leap year)
Indicate which line of the algorithm tells you whether the date is a leap year in
each of the following cases:
a. 1900 Line =
b. 1945 Line =
c. 1600 Line =
d. 1492 Line =
e. 1776 Line = - a. 1900 Line = 6
b. 1945 Line = 2
c. 1600 Line = 7
d. 1492 Line = 4
e. 1776 Line = 4
How would you extend the leap year algorithm to tell you also when a year is a
millennium year (a multiple of 1000)? - Divide by 1000 and see if the remainder is
0.
LESSON 2 -
, Mark the following identifiers as either valid or invalid.
a. theDog e. DVD_ROM
b. all - In - On f. Elizabeth_the_2nd
c. const g. 2morrow
d. recycling h. page# - a. valid
b. invalid (hyphens not allowed)
c. invalid (reserved words not allowed)
d. valid
e. valid
f. valid
g. invalid (must begin with a letter)
h. invalid (# is not allowed)
Write a single output statement that outputs the following three lines:
He said, "How is that possible?"
She replied, "Using manipulators."
"Of course!" he exclaimed. - Note that the \" escape sequence is needed in six
places here:
cout << "He said, \"How is that possible?\"" << endl
<< "She replied, \"Using manipulators.\"" << endl
<< "\"Of course,\" he exclaimed!" << endl;
What is the result of each of the following expressions?
a. 27 + - 7
b. 27.0 + 8..0 - 7.0
Les avantages d'acheter des résumés chez Stuvia:
Qualité garantie par les avis des clients
Les clients de Stuvia ont évalués plus de 700 000 résumés. C'est comme ça que vous savez que vous achetez les meilleurs documents.
L’achat facile et rapide
Vous pouvez payer rapidement avec iDeal, carte de crédit ou Stuvia-crédit pour les résumés. Il n'y a pas d'adhésion nécessaire.
Focus sur l’essentiel
Vos camarades écrivent eux-mêmes les notes d’étude, c’est pourquoi les documents sont toujours fiables et à jour. Cela garantit que vous arrivez rapidement au coeur du matériel.
Foire aux questions
Qu'est-ce que j'obtiens en achetant ce document ?
Vous obtenez un PDF, disponible immédiatement après votre achat. Le document acheté est accessible à tout moment, n'importe où et indéfiniment via votre profil.
Garantie de remboursement : comment ça marche ?
Notre garantie de satisfaction garantit que vous trouverez toujours un document d'étude qui vous convient. Vous remplissez un formulaire et notre équipe du service client s'occupe du reste.
Auprès de qui est-ce que j'achète ce résumé ?
Stuvia est une place de marché. Alors, vous n'achetez donc pas ce document chez nous, mais auprès du vendeur CleanA. Stuvia facilite les paiements au vendeur.
Est-ce que j'aurai un abonnement?
Non, vous n'achetez ce résumé que pour €12,68. Vous n'êtes lié à rien après votre achat.