Skip to content

Latest commit

 

History

History
44 lines (35 loc) · 2.16 KB

File metadata and controls

44 lines (35 loc) · 2.16 KB

Module 3: Control Structures

Activity 1: Conditional statements

  • Understanding conditional statements and their role in programming.
  • Exploring the if statement and its syntax.
  • Using comparison operators (==, !=, >, <, >=, <=) to create conditions.
  • Understanding the else if and else statements for handling multiple conditions.

Activity 2: Looping statements

  • Understanding looping statements and their role in repeating actions.
  • Exploring the for loop and its syntax.
  • Using the for loop to iterate over a range of values.
  • Exploring the while loop and its syntax.
  • Understanding the do-while loop and its differences from the while loop.

Practice Exercises:

  1. Print even numbers:

    • Write a program that prints all even numbers from 1 to 20.
    • Use a looping statement to iterate over the numbers.
    • Check if each number is even using a conditional statement.
    • Print the even numbers to the console.
  2. Temperature conversion:

    • Write a program that converts temperatures from Celsius to Fahrenheit.
    • Prompt the user for a temperature in Celsius.
    • Use a conditional statement to check if the input is valid.
    • If valid, convert the temperature to Fahrenheit using the formula: F = (C * 9/5) + 32.
    • Print the converted temperature to the console.
  3. Find the maximum number:

    • Write a program that finds the maximum number from a given array of numbers.
    • Use a loop to iterate over the array elements.
    • Keep track of the maximum number encountered so far using a variable.
    • After the loop, print the maximum number to the console.

Estimated time to complete this module is approximately 4-6 hours.

To further enhance your learning, here are some additional resources: