Skip to main content

✍️ Practice (While)

1. Spot the Problems​

This program prints the 7 multiplication table:

Console.WriteLine("7 x 1 = 7");
Console.WriteLine("7 x 2 = 14");
Console.WriteLine("7 x 3 = 21");
Console.WriteLine("7 x 4 = 27");
Console.WriteLine("7 × 5 = 35");
Console.WriteLine("7 x 6 = 42");
  1. Find the two mistakes.
  2. How many lines would you need to change to print the 8 times table instead?
  3. How would you let the user choose which time table to print?

2. Times Table​

Rewrite the program using a while loop. It should:

  • ask the user which times table to print,
  • print that table from 1 to 10.

3. Bart's Blackboard​

Like Bart Simpson writing lines on the chalkboard, write a program that prints a message as many times as the user asks.

bart

4. Fibonacci​

Write a C# program to find and print the first 10 Fibonacci numbers using a while loop.

Each Fibonacci number is the sum of the two before it: 0, 1, 1, 2, 3, 5, 8, 13, ...