CS2010 - Short Answer

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

Part 2

Last updated 5:27 PM on 12/9/25
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

15 Terms

1
New cards

Write a for loop that iterates exactly 109 times.

for (int i=0; i<109; i++) {}

2
New cards

Write a for loop that prints even numbers from 0 to 198 (100 numbers).

for (int i=0; i<200; i+=2) cout << i << " ";

3
New cards

Write an if statement that prints “Game over” if player1 won OR turns > 30.

if (player1 || turns > 30) cout << "Game over";

4
New cards

Write C++ code to initialize integer array scores[50] to 0.

int scores[50] = {0};

5
New cards

Write one statement that prints: 32° F

(ASCII 167)

cout << "32" << char(167) << " F";

6
New cards

Show the contents of char array after: char letters[10] = "Dog";

while (fin >> x) {}

7
New cards

State De Morgan’s Law for: p && q

p && q == !( !p || !q )

8
New cards

{'D','o','g','\0',?, ?, ?, ?, ?, ?}

9
New cards

What does indentation help prevent?

  • Prevents logical mistakes, improves readability.

10
New cards

Name the three types of programming errors.

  • Syntax, Runtime, Logic.

11
New cards

Convert this to C++:

C = sqrt(A*A + B*B);

12
New cards

Write the rules for naming identifiers in C++.

  • Letters/digits/_; no spaces; cannot start with digit; no keywords; case sensitive.

13
New cards

What library must be included to use string?

#include <string>

14
New cards

What is the best use of a for loop?

  • When the number of iterations is known.

15
New cards

Write an expression that produces a random integer 0–99.

rand() % 100;