0% found this document useful (0 votes)
4 views10 pages

Module 2

This document outlines a lesson plan for a Computer Programming 1 course focused on the C programming language. It covers the introduction to C, program structure, variables, data types, and operators, along with learning objectives, discussion topics, class activities, and assessments for each lesson. The plan includes hands-on labs and quizzes to reinforce learning and practical application of concepts.

Uploaded by

rishaisirani162
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Module 2

This document outlines a lesson plan for a Computer Programming 1 course focused on the C programming language. It covers the introduction to C, program structure, variables, data types, and operators, along with learning objectives, discussion topics, class activities, and assessments for each lesson. The plan includes hands-on labs and quizzes to reinforce learning and practical application of concepts.

Uploaded by

rishaisirani162
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Course Title : Computer Programming 1

Section :
Instructor : Mr. Mabud J. Amirul

Module 2

Day 1 Lesson Plan – Introduction to C and Program Structure

Introduction
This lesson introduces students to the C programming language, its history, importance, and
the basic structure of a C program. Students will learn how to write and execute a simple C
program while understanding syntax rules such as case sensitivity, semicolons, and braces.

Learning Objectives
• Explain the history and importance of the C programming language.

• Describe the general structure of a C program.

• Identify and apply syntax rules in writing simple C programs.

• Write and run a simple 'Hello World' program in C.

Lesson Flow

1. Motivation / Icebreaker (5 minutes)


Ask students: 'What is the first thing you do when you meet someone new?'
Likely answer: 'Say Hello!'

Connect this to programming:


In programming, the very first program we usually write is called the 'Hello World'
program. Just like how greetings start a conversation, 'Hello World' starts your journey into
coding.
2. Discussion Part 1: History and Importance of C (10 minutes)
• Developed in the early 1970s by Dennis Ritchie at Bell Labs.
• Created to improve upon the B language and to write the UNIX operating system.
• Known as a middle-level language (close to machine efficiency, but still human-readable).

Importance of C:
• Influenced many other modern languages: C++, Java, Python, PHP.
• Used in operating systems, embedded systems, compilers, and hardware drivers.
• Portable – runs on different machines with little modification.
• Efficient – programs written in C are very fast.

3. Discussion Part 2: Structure of a C Program (15 minutes)


A simple C program:

#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}

Explanation of parts:
• #include <stdio.h> – standard input/output library.
• int main() – entry point of the program.
• { } – enclose statements.
• printf() – outputs text to the screen.
• return 0 – signals successful program termination.

4. Discussion Part 3: Syntax Rules in C (10 minutes)


Syntax rules:
1. Case-sensitive (main ≠ Main).
2. Semicolons (;) end statements.
3. Curly braces { } group statements.
4. Indentation – not required but good practice.

Sample error code:


#include <stdio.h>
int main() {
printf("Hello World!") ;
return 0;
}
5. Class Activity (10 minutes)
Hands-on Lab:
• Students type and run the 'Hello World' program.
• Challenge: Modify the program to print their name, course, and year level.

Example:
printf("My name is ALBERT A. JASON\n");
printf("I am a BSIS 2nd Year Student\n");

Assessment

Short Quiz (5 pts)


1. Who is the creator of the C programming language?

4. True or False: Main() and main() are the same in C.

Day 2 – Variables and Data Types in C


Introduction
This lesson introduces variables and data types in the C programming language. Students
will learn how to declare, initialize, and use variables of different types. Understanding
variables and data types is essential because they define how data is stored and
manipulated in a program.

Learning Objectives
• Explain the concept of variables and constants in C.

• Differentiate between common data types (int, float, char, double).

• Declare and initialize variables correctly in C.

• Use variables in arithmetic and input/output operations.


• Apply naming rules and best practices for variables.

Lesson Flow

1. Motivation / Icebreaker
Ask students: 'If you want to store your money safely, where would you keep it?'

Connect this idea to programming: Just like wallets store money, variables store data in
programs.

2. Discussion Part 1: Variables


• Variables are named storage locations in memory that hold values.
• They must be declared before use.

Syntax:
datatype variableName = value;

Example:
int age = 20;
float gpa = 2.5;
char grade = 'A';

3. Discussion Part 2: Data Types


C supports several basic data types:
• int – integers (whole numbers), e.g., 5, -10
• float – floating-point numbers (decimal), e.g., 3.14
• double – larger precision decimal numbers
• char – single character, e.g., 'A'

Constants can be declared using the 'const' keyword to prevent changes:


const int DAYS_IN_WEEK = 7;

4. Discussion Part 3: Variable Naming Rules


Rules for naming variables:
1. Must begin with a letter or underscore (_).
2. Cannot contain spaces or special symbols.
3. Case-sensitive (score ≠ Score).
4. Should be meaningful names (e.g., age, total, average).

5. Class Activity (10 minutes)


Hands-on Lab:
• Write a program that declares variables for name, age, and grade.
• Print the values using printf().
Example Code:

#include <stdio.h>

int main() {
int age = 20;
float gpa = 2.5;
char grade = 'A';

printf("Age: %d\n", age);


printf("GPA: %.2f\n", gpa);
printf("Grade: %c\n", grade);
return 0;
}

What the code does

#include <stdio.h> // lets you use printf

#include <stdlib.h> // (not used here, but common for general utilities)

int main()

int age = 20; // whole number

float gpa = 2.5; // decimal number

char grade = 'A'; // single character

printf("Age: %d\n", age); // print an int

printf("GPA: %.2f\n", gpa); // print a float with 2 decimal places

printf("Grade: %c\n", grade); // print a character

return 0;

If you run it, the output is:


Age: 20

GPA: 2.50

Grade: A

(\n means “new line”.)

What the percent (%) means

In printf, the percent sign starts a format specifier—a placeholder that tells printf how to
format the next value you pass.

 %d → print an int (decimal integer).

 %f → print a floating-point number.

o %.2f → print a float with 2 digits after the decimal (rounded).

 %c → print a single char.

Other handy ones you’ll see later:

 %s for C-strings (char *)

 %ld for long

 %u for unsigned int

 %x for hexadecimal

To print a literal percent sign in the text, escape it as %%:

printf("Progress: 75%%\n"); // prints: Progress: 75%

Note: Outside printf (e.g., in arithmetic expressions), % means modulo (remainder), like 7
% 3 equals 1.

Assessment

Short Quiz (5 pts)


1. What is a variable in C?

2. Which data type is used for storing single characters?

3. Write the correct declaration for a float variable named 'temperature'.


4. True or False: 'Age' and 'age' are the same variable names in C.

5. What keyword is used to declare a constant variable?

Code Exercise (10 pts)


Write a program that declares and initializes the following variables:
- An integer for your age
- A float for your GPA
- A char for your section (e.g., 'A')

Then print all values with appropriate labels using printf().

Day 3 – Operators and Simple Programs


in C
Introduction
This lesson introduces operators in the C programming language. Students will learn how to
use arithmetic, relational, logical, and assignment operators to perform operations on
variables. They will also practice writing simple programs that apply these operators to
solve basic computational problems.

Learning Objectives
• Identify different types of operators in C.

• Apply arithmetic, relational, logical, and assignment operators in expressions.

• Write simple C programs that perform calculations and comparisons.

• Demonstrate the use of operators in input/output operations.


Lesson Flow

1. Discussion Part 1: Arithmetic Operators


Arithmetic operators are used for mathematical operations:
• + (addition)
• - (subtraction)
• * (multiplication)
• / (division)
• % (modulus)

Example Code:
int a = 10, b = 3;
printf("Sum = %d\n", a + b);
printf("Remainder = %d\n", a % b);

2. Discussion Part 2: Relational Operators


Relational operators are used to compare values:
• == (equal to)
• != (not equal to)
• > (greater than)
• < (less than)
• >= (greater than or equal to)
• <= (less than or equal to)

Example Code:
int x = 5, y = 10;
printf("Is x less than y? %d\n", x < y);

3. Discussion Part 3: Logical Operators


Logical operators are used for combining conditions:
• && (logical AND)
• || (logical OR)
• ! (logical NOT)

AND & OR ||

TT = T TT = T

TF = F TF = T

FT = F FT = T

FF=F FF = F
Example Code:
int age = 18;
int citizen = 1;
printf("Eligible to vote? %d\n", (age >= 18 && citizen == 1));

4. Discussion Part 4: Assignment Operators


Assignment operators are used to assign values to variables:
• = (simple assignment)
• +=, -=, *=, /=, %= (compound assignments)

Example Code:
int num = 10;
num += 5; // num = num + 5
printf("Updated value of num: %d\n", num);

5. Class Activity
Hands-on Lab:
• Write a program that accepts two integers and prints their sum, difference, product, and
quotient.
• Write a program that checks if a number is even or odd using the modulus operator.

Example Code for Even/Odd:


#include <stdio.h>

int main() {
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0) {
printf("%d is even.\n", num);
} else {
printf("%d is odd.\n", num);
}
return 0;
}

Assessment

Short Quiz (5 pts)


1. Which operator is used to find the remainder of a division?
2. What is the difference between == and = in C?

3. Write the relational operator for 'greater than'.

4. True or False: The logical AND operator is represented by &&.

5. What will be the output of: int a=10; a+=5; printf("%d", a); ?

Code Exercise (10 pts)


Write a program that:
- Accepts two numbers from the user.
- Performs and displays results for addition, subtraction, multiplication, division, and
modulus.
- Compares the two numbers and displays whether the first is greater, less, or equal to the
second.

You might also like