User:Saroj Neupane Lesson Plan 8: Difference between revisions

From ICTED-WIKI
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 39: Line 39:


* Show the syntax for declaring an array and initializing it.
* Show the syntax for declaring an array and initializing it.
* Syntax:   data_type array_name[array_size];  //Declaration of array Example: int marks[5];
* Syntax: data_type array_name[array_size];  //Declaration of array Example: int marks[5];


* marks[0]=80;//initialization of array   
* marks[0]=80;//initialization of array   
Line 54: Line 54:
* Explain how to access individual elements using index notation.
* Explain how to access individual elements using index notation.


int x = numbers[2];  // Access the third element (index 2) of the array
* int x = numbers[2];  // Access the third element (index 2) of the array<br />
 
 


'''Code Demonstration (4 minutes):'''
'''Code Demonstration (4 minutes):'''
Line 64: Line 62:
#include <stdio.h>
#include <stdio.h>


int main() {
# int main() {
    int numbers[5] = {1, 2, 3, 4, 5};
# int numbers[5] = {1, 2, 3, 4, 5};
 
# for (int i = 0; i < 5; i++) {
    for (int i = 0; i < 5; i++) {
# printf("Element %d: %d\n", i, numbers[i]);
        printf("Element %d: %d\n", i, numbers[i]);
# }
    }
# return 0;
 
# }
    return 0;
}


'''Conclusion (2 minutes):'''
'''Conclusion (2 minutes):'''
Line 83: Line 79:
* What is array? How to declare and initialize array in c?
* What is array? How to declare and initialize array in c?
* Write simple program of array in c ?
* Write simple program of array in c ?
[[Category:Lesson Plan]]
__notoc__

Revision as of 09:25, 4 December 2023

Subject : Computer Science

Period: 3rd

Topic: Array in C Programming

School: ABC School

Class: 10

Unit: Seven

Time: 15 min

No. of Students: 20

Specific Objectives

By the end of this brief lesson, students should be able to:

  • Understand the concept of arrays in C programming.
  • Declare, initialize, and access elements in an array.

Teaching Materials

  • Whiteboard and markers
  • Quick access to a C compiler for live coding demonstration

Teaching Learning Activity

Introduction (3 minutes):

  • Briefly review the concept of variables.
  • Introduce the need for handling multiple values efficiently.
  • Explain that arrays are collections of similar elements stored in contiguous memory locations.
  • The array is the simplest data structure where each data element can be randomly accessed by using its index number.

Declaration and Initialization (5 minutes):

  • Show the syntax for declaring an array and initializing it.
  • Syntax: data_type array_name[array_size]; //Declaration of array Example: int marks[5];
  • marks[0]=80;//initialization of array
  • marks[1]=60;
  • marks[2]=70;
  • marks[3]=85;
  • marks[4]=75;
  • Declaration with Initialization:
  • int numbers[5] = {1, 2, 3, 4, 5};

Accessing Array Elements (3 minutes):

  • Explain how to access individual elements using index notation.
  • int x = numbers[2]; // Access the third element (index 2) of the array

Code Demonstration (4 minutes):

Quickly demonstrate a simple code example on the whiteboard.

  1. include <stdio.h>
  1. int main() {
  2. int numbers[5] = {1, 2, 3, 4, 5};
  3. for (int i = 0; i < 5; i++) {
  4. printf("Element %d: %d\n", i, numbers[i]);
  5. }
  6. return 0;
  7. }

Conclusion (2 minutes):

  • Summarize the key points: Arrays store multiple values of the same type.
  • Encourage students to practice declaring, initializing, and accessing arrays.

Evaluation

  • What is array? How to declare and initialize array in c?
  • Write simple program of array in c ?