Write Up Part B Journal Program 8,9,10,11
Write Up Part B Journal Program 8,9,10,11
Title: Write a program to read two matrices and perform addition and subtraction on them
Arrays
Definition 1:
An array is a group of related data items that share a common name and a common data type.
Two-Dimensional Arrays
Two-dimensional array is defined as group of homogeneous elements that share common name and
are accessed by using two indices or subscripts. We can refer two-dimensional array as “array of
one-dimensional array”.
Pictorially, two-dimensional array can be represented as a table consisting to some rows and columns.
Syntax:
data_type array_name[row_size][col_size];
where, data_type : specifies the type of elements that will be stored in the array
array_name : specifies the name of the array
row_size : specifies the maximum number of rows that can be stored in the array.
col_size : specifies the maximum number of columns that can be stored in the array.
The total elements that can be stored in a two-dimensional array is equal to (row_size * col_size).
[ 2 4 6
1 3 5 ] 2X3
Write Up –Part B 09
Title: Write a program to read, display and multiply two m x n matrices.
Functions
Definition :
A function is a subprogram or a sub routine that performs a specific task.
There are two categories of functions in C.
1. Library Functions 2. User-Defined Functions
Library Functions : These functions come along with C programming language. Hence, they are
also known as built-in functions. These functions are grouped in various header files.
Example: printf(), scanf(), sqrt(), strcat()
User-Defined Functions: User-defined functions are created and defined by the user or the
programmer that performs a specific task.
Example: addition(),sum(),isprime()
Example:
Example:
Write Up –Part B 11
Title: Write a program using functions that takes in three arguments - a start temperature (in Celsius), an end
temperature (in Celsius) and a step size. Print out a table that goes from the start temperature to the end
temperature, in steps of the step size; converting each Celsius to Fahrenheit.
Global variables are variables that are declared outside of any function or block, usually at the top level of a
program. Their scope is not limited to a specific function, meaning they can be accessed and modified from
any part of the program, including within functions.