0
0
C Sharp (C#)programming~15 mins

Continue statement behavior in C Sharp (C#) - Mini Project: Build & Apply

Choose your learning style9 modes available
Continue Statement Behavior
📖 Scenario: Imagine you are checking a list of daily temperatures to find which days were warm enough to go outside. You want to skip cold days and only note the warm days.
🎯 Goal: You will write a program that uses the continue statement to skip cold days and print only the warm days from a list of temperatures.
📋 What You'll Learn
Create an integer array called temperatures with the exact values: 15, 22, 8, 30, 12
Create an integer variable called warmThreshold and set it to 20
Use a for loop with the variable i to iterate over temperatures
Inside the loop, use an if statement to continue when the temperature is less than warmThreshold
Print the warm temperatures only using Console.WriteLine
💡 Why This Matters
🌍 Real World
Skipping unwanted data is common when processing lists, like ignoring cold days when planning outdoor activities.
💼 Career
Understanding how to control loops with <code>continue</code> helps in writing efficient code that processes only needed data.
Progress0 / 4 steps
1
Create the temperature data
Create an integer array called temperatures with these exact values: 15, 22, 8, 30, 12.
C Sharp (C#)
Need a hint?

Use int[] temperatures = { ... }; to create the array with the exact numbers.

2
Set the warm temperature threshold
Create an integer variable called warmThreshold and set it to 20.
C Sharp (C#)
Need a hint?

Use int warmThreshold = 20; to set the threshold.

3
Use a for loop with continue to skip cold days
Use a for loop with the variable i to iterate over temperatures. Inside the loop, use an if statement to continue when temperatures[i] is less than warmThreshold.
C Sharp (C#)
Need a hint?

Use for (int i = 0; i < temperatures.Length; i++) and inside it, if (temperatures[i] < warmThreshold) continue;.

4
Print only the warm temperatures
Inside the for loop, after the continue statement, add a Console.WriteLine statement to print temperatures[i].
C Sharp (C#)
Need a hint?

Use Console.WriteLine(temperatures[i]); to print the warm temperatures.