Array_in_C_Practical_Work_Formatted
Array_in_C_Practical_Work_Formatted
Syntax of Array in C
data_type array_name[size];
Example
int numbers[5] = {10, 20, 30, 40, 50};
This array stores 5 integer values. The indexing starts from 0, so:
- numbers[0] = 10
- numbers[1] = 20
- and so on...
Types of Arrays
1. Single-Dimensional Array
Syntax:
int arr[5];
2. Multi-Dimensional Array
Syntax:
int arr[3][4]; // 3 rows, 4 columns
Example of 2D Array
int matrix[2][3] = {1, 2, 3},{4, 5, 6}
Difference Between Single and Multi-Dimensional Array
Feature Single-Dimensional Multi-Dimensional
Array Array
Structure Stores data in a single Stores data in rows and
row columns
Syntax int arr[5]; int arr[2][3];
Access Element arr[2] arr[1][2]
Example Use List of marks, ages, Matrices, tables, etc.
etc.
Memory Usage Less complex More complex due to
nested arrays
What is an array?
- Arrays are static, meaning their size must be declared at the start.
- The size should be a constant or known value.
- They can store primitive types (int, char, float, etc.) or even structures.
- Arrays help in loop-based operations like sorting, searching, etc.
- C does not check bounds, so accessing out-of-bound index may cause
errors.
Objectives
To understand the concept of array
(single dimesnion and Multi Dimensional Array)
To perform sorting of array.
To perform matrix operation using array(sum,transpose)
Conclusion
Through this practical exercise, I have gained a clear understanding of
arrays, including both single- and multi-dimensional types. I successfully
implemented sorting techniques using arrays, which helped me understand
how data can be arranged efficiently. Additionally, performing matrix
operations such as sum and transpose using multidimensional arrays
enhanced my logical thinking and programming skills. This practical has
strengthened my foundation in array handling and improved my problem-
solving ability in C programming.
TRINITY INTERNATIONAL SS &COLLEGE
KATHMANDU, NEPAL
2025
Submitted By:
Name: Krishal Upreti Submitted To:
Grade: Eleven Sanjay Phuyal
Date: 2081/12/25 Department of Computer
Lab Sheet #3
(C-Program)
Krishal Upreti
2081/10/25
REFERENCES