1/14
Part 2
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Write a for loop that iterates exactly 109 times.
for (int i=0; i<109; i++) {}
Write a for loop that prints even numbers from 0 to 198 (100 numbers).
for (int i=0; i<200; i+=2) cout << i << " ";
Write an if statement that prints “Game over” if player1 won OR turns > 30.
if (player1 || turns > 30) cout << "Game over";
Write C++ code to initialize integer array scores[50] to 0.
int scores[50] = {0};
Write one statement that prints: 32° F
(ASCII 167)
cout << "32" << char(167) << " F";
Show the contents of char array after: char letters[10] = "Dog";
while (fin >> x) {}
State De Morgan’s Law for: p && q
p && q == !( !p || !q )
{'D','o','g','\0',?, ?, ?, ?, ?, ?}
What does indentation help prevent?
Prevents logical mistakes, improves readability.
Name the three types of programming errors.
Syntax, Runtime, Logic.
Convert this to C++:
C = sqrt(A*A + B*B);
Write the rules for naming identifiers in C++.
Letters/digits/_; no spaces; cannot start with digit; no keywords; case sensitive.
What library must be included to use string?
#include <string>
What is the best use of a for loop?
When the number of iterations is known.
Write an expression that produces a random integer 0–99.
rand() % 100;