# CSCI 103 Fall 2017: Introduction to Programming

## In-Class Exercises Set 1

### Lecture 1

None

### Lecture 2

#### Checkpoint 1

#### Checkpoint 2

### Lecture 3

#### Conditionals (if..else)

### Lecture 4

#### Loops 1

#### Loops 2

### Lecture 5

#### Random Number Generation

#### Common Loop Tasks: Search and/or Selection

#### Common Loop Tasks: Aggregation

#### Arrays

#### Array Challenge Problems

#### Example 1

This code has a bug (it's not in the initializer). It will print out false no matter what password you type in. Why?

```
int secret_password[4] = {2, 0, 1, 4};
int input[4];
cout << "Please enter your password, one digit per line.";
cin >> input[0] >> input[1] >> input[2] >> input[3];
if (input == secret_password)
cout << "Access granted!";
```

#### Array Challenge Problem on your VM: Secret Sequence Game

Write a game program that will generate a secret sequence of 4 random numbers between 1 and 3.

Then allow the user up to 8 turns to guess the correct sequence of 4 numbers.

(taking in 4 values each turn separated by spaces). After each guess follow the procedure below:

- Output
`correct`and quit if the guess is correct. - Output
`game over`if they did not guess the sequence correctly after 8 turns - Output the number of matches between the guess and the secret sequence (i.e. if the secret sequence is

`2 2 1 3`and the user guesses`2 1 3 3`output`2`since they had 2 of the

numbers in their guess matching the corresponding numbers in the secret sequence)