LAST Name: FIRST Name: (1) C program. Write C code make a "counting by" program. It will count by 2's, or 3's, or whatever user asks for. Here is a sample transcript. > ./countBy program: Welcome to the count by program. What integer would you like to count by? user: 4 program: I will count by 4's. After each number, type ok. Type quit to quit. program: 0 user: ok program: 4 user: ok program 8 user: ok program: 12 user: quit program: You typed quit. The numbers have saved into countBy.txt. Bye! The program should both print the numbers to the screen and write them into a file called countBy.txt (2) C++ program. /* Make a class that implements a set of integers. A few functions are given to you below. You need to finish the contains function, and make all the overloaded operators that are needed. Note that a set should not have duplicates */ class set { private: vector numbers; public: void print() { for(int i=0; i < numbers.size(); i++) { cout << numbers[i] << " "; } cout << endl; } void removeNumber(int x) { for(int i=0; i < numbers.size(); ) { if (numbers[i] == x) numbers.erase(numbers.begin()+i); else i++; } } bool contains(int x) { // return true if x is in the set, false otherwise. } void addNumber(int x) { if (!contains(x)) numbers.push_back(x); } }; int main() { set A; //A += 3; //A += 7; //A += 3; // prints the set A, which should be {3, 7} A.print(); set B; //B = A; // prints the set B, which should be {3, 7} B.print(); //B += 5; //B += 1; //B -= A; // prints the set B, which should be {1, 5} B.print(); //if (B == A) cout << "Same" << endl; //else cout << "Not same" << endl; return 0; } (3) What does C program do? For each, write down exactly what gets printed, and in the right order. Show your work if you like. (3a) void func(int x) { printf("%i\n", x); if (x >= 13) return; func(x+1); func(x+2); } int main() { func(10); func(11); return 0; } (3b) int main() { int i, j; for(j = 0; j < 5; j++) { printf(" %i", j); } printf("\n"); for(i=0; i < 5; i++) { printf("%i: ", i); for(j=0; j < i; j++) { printf("%2i ", i*j); } } return 0; } (3c) int main() { int x = 2; if (x < 5) { int x = 0; printf("x < 5\n"); } if (x < 2) { printf("x < 2\n"); } else { printf("not x < 2\n"); } } (4) What does C++ program do? Write down exactly what this C++ program prints. class person { public: string name; person() { name = ""; } person(string s) { name = s; } void print() { cout << name << endl; } }; class family { public: vector people; void add(const person & p) { people.push_back(p); } void print() { cout << "--family--..." << endl; for(int i=0; i < people.size(); i++) people[i].print(); } family & operator=(const family &rhs) { for(int i=0; i < people.size(); i++) people.erase(people.begin()+i); for(int i=0; i < rhs.people.size(); i++) people.push_back(rhs.people[i]); return *this; } }; int main() { person x, y("cat"); person z("dog"), w("mouse"); family f1; f1.add(x); f1.add(y); f1.add(y); f1.print(); family f2 = f1; f2.add(z); f2.print(); return 0; }