1. Rolling N Dice

Read a number N from the console. Simulate rolling N 6-sided dice. Write the value of each die roll, followed by the sum of all of them.

How many dice? 4
6 2 6 1
total: 15
===
How many dice? 2
6 2
total: 8

2. Flipping a Coin

Simulate coin flips, printing an 'H' each time the coin falls on heads and 'T' each time it falls on tails. Once you reach the third H, stop and write how many coins were flipped.

HTTTHTH
7 flips
===
TTTHTTTTTHH
11 flips

3. Average

Read a set of floating-point numbers from the console until the user presses ctrl+D (Unix, macOS) or ctrl-Z (Windows). Print their average.

2.5
3.5
5.5
6.5
^D
4.5

4. Positive and Negative

Read integers from the console until the user presses ctrl+D or ctrl+Z. Write the sum of the positive integers and the sum of the negative integers.

Enter numbers:
4
2
-6
-1
5
-2
^D
Positive sum: 11
Negative sum: -9

5. Equal To The First

Read integers from the console until the user presses ctrl+D or ctrl+Z. Write a number indicating how many of the integers were equal to the first one (not including the first one itself).

Enter numbers:
4
2
2
8
4
4
3
^D
2 numbers were equal to 4
===
Enter numbers:
5
3
6
^D
0 numbers were equal to 5

6. Second Largest

Write a program that reads a series of non-negative integers from standard input until the user presses Ctrl+D or Ctrl+Z. The program should then print the second largest of the integers that were read.

7. Square

Read a number N, then print an N x N square of asterisks as in the example below.

Enter N: 5
*****
*   *
*   *
*   *
*****

8. Triangle

Read a number N, then print an N x N triangle of asterisks as in the example below.

Enter N: 6
     *
    **
   ***
  ****
 *****
******

9. AEIOU

Write a program that reads a string on a single line and prints "vowels" if the string contains any vowels, otherwise "no vowels".

10. ASCII or Unicode

Read a string and print either 'ascii' if the string contains only ASCII characters, 'unicode' otherwise.

11. Spaces In Between

Read a string and write it out with a space between each adjacent pair of characters.

Enter string: waffle
w a f f l e