0% found this document useful (0 votes)
14 views20 pages

4 Array

Uploaded by

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

4 Array

Uploaded by

jenesaf276
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Academic Session 2025-26

ODD Semester Jul-Dec 2025

INSTITUTE - UIE
Department of Engineering Foundations
Bachelor of Engineering (All NON-IT)
Subject Name: Programming for Problem Solving
Code:25CSH-101

Unit No. 2 Chapter No. 2 Lecture No.4

Topic : Arrays
Faculty Name-Dr. Anupam Mittal
E_Code – E1437
Designation-Associate Professor
Academic Session 2025-26
ODD Semester Jul-Dec 2025

INSTITUTE - UIE
DEPARTMENT- ACADEMIC UNITS
Bachelor of Engineering (Computer Science & Engineering)
Subject Name: Logical Thinking & Problem Solving
Code:25CSH-107

Unit No. 2 Chapter No. 2 Lecture No.1

Topic : Loops

Faculty Name-Dr. Sheenam

E_Code - E6717

Designation-Assistant Professor
Logical Thinking
& Problem
Solving
Course Objectives
The course aims to provide a strong foundation
in problem-solving using the C programming
language.
It enhances students' programming skills by
developing logical thinking and algorithmic
problem-solving abilities
By mastering C programming concepts, students
will be able to design and implement efficient
solutions for real-world problems
Course Outcomes

CO No Statement

To remember the concepts related to fundamentals of C language, Algorithm/


CO1
pseudocode, Flowcharts and Problem solving

CO2 To understand the way of execution and debug programs in C language.

To apply various constructs, loops, functions to solve mathematical and scientific


CO3
problem.

CO4 To analyse the dynamic behaviour of memory by the use of pointers.

To design and develop modular programs for real world problems using control
CO5
structure and selection structure.
Scheme of Evaluation
Frequency of Final Weightage
Direct Evaluation Weightage of actual
S. No. Assessment tool in Internal
Instruments conduct Task Assessment
Unit-1 Practical 15 Marks Code-Blocks & Dev C
1 Evaluation
15 Marks Hacker Rank
2 Unit-2 Practical
Evaluation
3
Unit-3 Practical 15 Marks Code Fix problems
Evaluation / Mini
3 Project 45

Lab MST 15 Marks for one Online GDB compiler 1 per semester
4 MST 15

External Exam 40 Marks Hacker Rank 1 per semester


5
40
6 Attendance NA NA NA NA 5
• Array
• Types of Array
• Declaration of One Dimensional
CONTENTS Array
• Initialization of One Dimensional
Array
• Examples
• References

6
ARRAY
In C programming, one of the frequently arising problem is to handle
similar types of data.
For example: If the user want to store marks of 100 students. This can
be done by creating 100 variable individually but, this process is rather
tedious and impracticable. These type of problem can be handled in C
programming using arrays.
An array is a sequence of data item of homogeneous value(same type).
All the data items of an array are stored in consecutive memory
locations in RAM.
The elements of an array are of same data type and each item can be
accessed using the same name.
7
TYPES OF ARRAYS
• Array is of three types:

8
Declaration of 1-D Array
•Declaration of one-dimensional array: We know that all the variables are declared before they are
used in the program. Similarly, an array must be declared before it is used.
•During declaration, the size of the array has to be specified. The size used during declaration of the
array informs the compiler to allocate and reserve the specified memory locations.

data_type array_name[array_size];

For example:

int age[5];

Here, the name of array is age. The size of array is 5,i.e., there are 5 items(elements) of array age.
All element in an array are of the same type (int, in this case).

9
Array Elements
• Each element of array can be accessed and used by user according to the need of
program.
For example:
int age[5];

• Note that, the first element is numbered 0 and so on.


• Here, the size of array age is 5 times the size of int because there are 5 elements.
• Suppose, the starting address of age[0] is 2120d and the size of int be 4 bytes.
Then, the next address (address of a[1]) will be 2124d, address of a[2] will
be2128d and so on.

10
Initialization of 1-D Array
Initialization of one-dimensional array:
• Arrays can be initialized at declaration time in this source code as:

int age[5]={2,4,34,3,4};
• It is not necessary to define the size of arrays during initialization.

int age[]={2,4,34,3,4};
• In this case, the compiler determines the size of array by calculating the number
of elements of an array

11
Example of 1-D Array
Program to take 5 values from the user and store them in an array.
#include<stdio.h> printf("Displaying integers: ");
int main() { for(int i = 0; i < 5; ++i)
int values[5]; {
printf("Enter 5 integers: "); printf("%d\n", values[i]);
for(int i = 0; i < 5; ++i) }
{ return 0;
scanf("%d", &values[i]); }
}

Here, we have used a for loop to take 5 inputs from the


user and store them in an array. Then, using another for
loop, these elements are displayed on the screen 12
Example of 1-D Array
Program to find the average of n numbers using arrays
#include<stdio.h> average = sum/n;
int main() { printf("Average = %d", average);
int marks[10], i, n, sum = 0, average }
printf("Enter number of elements: "); return 0;
scanf("%d", &n); for(i=0; i<n; ++i) }
{
printf("Enter number%d: ",i+1);
scanf("%d", &marks[i]);
sum += marks[i];
}

Here, we have computed the average of n numbers


entered by the user.
13
Summary

• Array is defined as an ordered set of similar data items


• During declaration of an array the size of the array has to be
specified.
• Arrays can be initialized at declaration time in this source code

14
FREQUENTLY ASKED QUESTIONS
1. Write a C Program to Addition of All Elements of the Array
2. Write a C Program to insert an element in an array.
3. Write a C Find Smallest Element in Array .
4. Write a C program to reversing an element in an array.
5. C program to find the sum and calculate percentage of marks of n
students using arrays

15
UTILIZE YOUR KNOWLEDGE TO
ANSWER
1.What is the right way to initialize an array?
A.int num[6] = { 2, 4, 12, 5, 45, 5 };
B.int n{} = { 2, 4, 12, 5, 45, 5 };
C.int n{6} = { 2, 4, 12 };
D.int n(6) = { 2, 4, 12, 5, 45, 5 };

2. An array element is always stored in …………………..memory location?


A. Sequential
B. Random
C. Sequential and Random
D. None of the above
16
UTILIZE YOUR KNOWLEDGE TO
ANSWER
3. Size of an array need not be specified, when
A. Initialization is a part of definition
B. It is a declaratrion
C. It is a formal parameter
D. All of these

17
REFERENCES
Video Lectures
1. https://nptel.ac.in/courses/106/106/106106127/
2. https://nptel.ac.in/courses/106/105/106105171/
3. https://study.com/academy/lesson/declaring-one-dimensional-arrays-definition-example.html
4. https://www.youtube.com/watch?v=XZGZm-0wUC0

Websites:
5. https://www.cs.swarthmore.edu/~newhall/unixhelp/C_arrays.html
6. https://beginnersbook.com/2014/01/c-arrays-example/
7. https://www.codesdope.com/c-array/

18
Class-wise feedback
THANK YOU

You might also like