Learn with Yasir

Share Your Feedback

Prompt: Generate Programming Language Lab Exercises


Prompt: Generate Programming Language Lab Exercises

Create a beginner-friendly programming lab for a Programming Language course using the following learning pattern for every exercise:

Example → Understand the Code → Modify the Code → Solve a Similar Task

The lab must use the exact output format specified below for every exercise. Do not change, remove, or reorder the sections.


Learning Pattern

For every exercise, follow these four stages:

  1. Example — Show a simple working program.
  2. Understand the Code — Explain how the program works.
  3. Modify the Code — Students make guided changes to the existing program.
  4. Solve a Similar Task — Students independently solve a new but related problem.

Required Output Format

Every exercise MUST follow this exact structure:

Exercise [Number]: [Exercise Title]

Topic

[Programming concept being taught]

Learning Objective

By completing this exercise, students will be able to:

  • [Objective 1]
  • [Objective 2]

1. Example

Problem Statement: [Short and clear problem statement]

Input: [Describe the input]

Output: [Describe the required output]

Code:

// Complete working code

Expected Output:

[Exact sample output]

2. Understand the Code

What does the program do? [Simple explanation]

Step-by-Step Explanation:

  1. [Explain the first important part]
  2. [Explain the next part]
  3. [Explain the next part]
  4. [Explain how the output is produced]

Important Concepts:

  • Concept 1: [Explanation]
  • Concept 2: [Explanation]
  • Concept 3: [Explanation]

Key Syntax:

// Important syntax example

3. Modify the Code

Students should modify the Example program, rather than writing a completely new program.

Modification 1

Task: [Specific modification]

Expected Change: [What students should achieve]

Modification 2

Task: [Specific modification]

Expected Change: [What students should achieve]

Modification 3

Task: [Specific modification]

Expected Change: [What students should achieve]

Do not provide the solutions to the modifications unless explicitly requested.


4. Solve a Similar Task

Problem Statement: [New problem using the same concept but with a different scenario]

Input: [Required input]

Output: [Required output]

Requirements:

  • [Requirement 1]
  • [Requirement 2]
  • [Requirement 3]

Sample Input:

[Sample input]

Sample Output:

[Sample output]

Do not provide the solution code. Students must solve this task independently.


Exercise Check

Before moving to the next exercise, students should be able to answer:

  1. What programming concept was used?
  2. How does the example program work?
  3. What changes were made during the modification tasks?
  4. How is the final task similar to the example?
  5. What would happen if the input were changed?

Fixed Format Rules

For EVERY exercise, enforce the following rules:

  • Use exactly the same section order.
  • Do not skip any section.
  • Do not add unrelated sections.
  • Use the four-stage learning pattern: Example → Understand the Code → Modify the Code → Solve a Similar Task
  • Every Example must contain complete working code.
  • Every Example must contain Input, Output, Code, and Expected Output.
  • Every Modify the Code section must contain exactly 3 modification tasks.
  • Every Solve a Similar Task section must contain:

    • Problem Statement
    • Input
    • Output
    • Requirements
    • Sample Input
    • Sample Output
  • Do not provide the solution code for modification or independent tasks.
  • The independent task should be slightly more challenging than the Example.
  • Do not introduce programming concepts that have not yet been taught.
  • Keep the difficulty appropriate for beginners.
  • Use meaningful variable names.
  • Explain code in simple language.
  • Use C++ unless another programming language is specified.

Final Lab Section

After all exercises, provide:

Final Practice Tasks

Create 3–5 independent programming problems that combine the concepts covered in the lab.

For each task, use this format:

Practice Task [Number]: [Title]

Problem Statement: …

Input: …

Output: …

Requirements:

  • …
  • …
  • …

Sample Input:

...

Sample Output:

...

Do not provide solutions.


Instructor Design Principle

Design the exercises so that students progressively move from:

Seeing a working example ↓ Understanding how it works ↓ Changing an existing program ↓ Writing a similar program independently

The goal is to make students understand and construct programs, rather than simply copy code.

Always maintain the same fixed structure for every exercise.