1.
Fix the code below so that it prints “THE TEAM” “THE TEAM” “THE TEAM” on three separate lines.
#include <iostream>
using namespace std;
void countBy2(int num) {
if (num < 9) {
cout << num;
countBy2(num + 2);
}
else {
cout << num << endl;
cout << "Done counting!";
}
}
int main() {
countBy2(5);
}
greaterThan
that prints true if the first double
argument is greater than the second double
argument.
goodVibes
that prints “I’m having a mood
day!” depending on the value of mood
. If mood
is “bad”, then the function should not do anything since it’s good vibes only. Be sure to include any necessary headers.
#include <iostream>
using namespace std;
void goodVibes(string mood) {
if (mood == "bad") {
return;
}
cout << "I'm having a " << mood << " day";
}
exclusiveOr
that prints true If either a
OR b
is true, and prints false otherwise.
countdown
that takes a positive integer and decrements it until eaching zero, printing the number at each step of the way. Once it reaches zero, it should print “Blastoff!”
printNegativeNum
that asks the user for a negative number. If the user does not provide a negative number, it should contine asking until the user provides one. It should then print the negative number.
printNegativeNum
that asks the user for a negative number. If the user does not provide a negative number, it should contine asking until the user provides one. It should then print the negative number. Use the lines to construct the code, then go back to complete the Activecode.