Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
Homework Assignment – Array Technical Document
Write a technical document that describes the structure and use of arrays. The document should
be 3 to 5 pages and include an Introduction section, giving a brief synopsis of the document and
arrays, a Body section, describing arrays and giving an annotated example of their use as a
programming construct, and a conclusion to revisit important information about arrays described
in the Body of the document. Some suggested material to include:
Declaring arrays of various types
Array pointers
Printing and processing arrays
Sorting and searching arrays
Multidimensional arrays
Indexing arrays of various dimension
Array representation in memory by data type
Passing arrays as arguments
If you find any useful images on the Internet, you can use them as long as you cite the source in
end notes.
Solution
Array is a collection of variables of the same type that are referenced by a common name.
Specific elements or variables in the array are accessed by means of index into the array.
If taking about C, In C all arrays consist of contiguous memory locations. The lowest address
corresponds to the first element in the array while the largest address corresponds to the last
element in the array.
C supports both single and multi-dimensional arrays.
1) Single Dimension Arrays:-
Syntax:- type var_name[size];
where type is the type of each element in the array, var_name is any valid identifier, and size is
the number of elements in the array which has to be a constant value.
*Array always use zero as index to first element.
The valid indices for array above are 0 .. 4, i.e. 0 .. number of elements - 1
For Example :- To load an array with values 0 .. 99
int x[100] ;
int i ;
for ( i = 0; i < 100; i++ )
x[i] = i ;
To determine to size of an array at run time the sizeof operator is used. This returns the size in
bytes of its argument. The name of the array is given as the operand
size_of_array = sizeof ( array_name ) ;
2) Initialisg array:-
Arrays can be initialised at time of declaration in the following manner.
type array[ size ] = { value list };
For Example :-
int i[5] = {1, 2, 3, 4, 5 } ;
i[0] = 1, i[1] = 2, etc.
The size specification in the declaration may be omitted which causes the compiler to count the
number of elements in the value list and allocate appropriate storage.
For Example :- int i[ ] = { 1, 2, 3, 4, 5 } ;
3) Multidimensional array:-
Multidimensional arrays of any dimension are possible in C but in practice only two or three
dimensional arrays are workable. The most common multidimensional array is a two
dimensional array for example the computer display, board games, a mathematical matrix etc.
Syntax :type name [ rows ] [ columns ] ;
For Example :- 2D array of dimension 2 X 3.
int d[ 2 ] [ 3 ] ;
A two dimensional array is actually an array of arrays, in the above case an array of two integer
arrays (the rows) each with three elements, and is stored row-wise in memory.
For Example :- Program to fill .
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
Homework Assignment – Array Technical Document
Write a technical document that describes the structure and use of arrays. The document should
be 3 to 5 pages and include an Introduction section, giving a brief synopsis of the document and
arrays, a Body section, describing arrays and giving an annotated example of their use as a
programming construct, and a conclusion to revisit important information about arrays described
in the Body of the document. Some suggested material to include:
Declaring arrays of various types
Array pointers
Printing and processing arrays
Sorting and searching arrays
Multidimensional arrays
Indexing arrays of various dimension
Array representation in memory by data type
Passing arrays as arguments
If you find any useful images on the Internet, you can use them as long as you cite the source in
end notes.
Solution
Array is a collection of variables of the same type that are referenced by a common name.
Specific elements or variables in the array are accessed by means of index into the array.
If taking about C, In C all arrays consist of contiguous memory locations. The lowest address
corresponds to the first element in the array while the largest address corresponds to the last
element in the array.
C supports both single and multi-dimensional arrays.
1) Single Dimension Arrays:-
Syntax:- type var_name[size];
where type is the type of each element in the array, var_name is any valid identifier, and size is
the number of elements in the array which has to be a constant value.
*Array always use zero as index to first element.
The valid indices for array above are 0 .. 4, i.e. 0 .. number of elements - 1
For Example :- To load an array with values 0 .. 99
int x[100] ;
int i ;
for ( i = 0; i < 100; i++ )
x[i] = i ;
To determine to size of an array at run time the sizeof operator is used. This returns the size in
bytes of its argument. The name of the array is given as the operand
size_of_array = sizeof ( array_name ) ;
2) Initialisg array:-
Arrays can be initialised at time of declaration in the following manner.
type array[ size ] = { value list };
For Example :-
int i[5] = {1, 2, 3, 4, 5 } ;
i[0] = 1, i[1] = 2, etc.
The size specification in the declaration may be omitted which causes the compiler to count the
number of elements in the value list and allocate appropriate storage.
For Example :- int i[ ] = { 1, 2, 3, 4, 5 } ;
3) Multidimensional array:-
Multidimensional arrays of any dimension are possible in C but in practice only two or three
dimensional arrays are workable. The most common multidimensional array is a two
dimensional array for example the computer display, board games, a mathematical matrix etc.
Syntax :type name [ rows ] [ columns ] ;
For Example :- 2D array of dimension 2 X 3.
int d[ 2 ] [ 3 ] ;
A two dimensional array is actually an array of arrays, in the above case an array of two integer
arrays (the rows) each with three elements, and is stored row-wise in memory.
For Example :- Program to fill .
Array
Introduction
One-dimensional array
Multidimensional array
Advantage of Array
Write a C program using arrays that produces the multiplication of two matrices.
An array is a group of data items of same data type that share a common name. Ordinary variables are capable of holding only one value at a time. If we want to store more than one value at a time in a single variable, we use arrays.
An array is a collective name given to a group of similar variables. Each member in the group is referred to by its position in the group.
Arrays are alloted the memory in a strictly contiguous fashion. The simplest array is a one-dimensional array which is a list of variables of same data type. An array of one-dimensional arrays is called a two-dimensional array.
computer dataA computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as programs. These programs enable computers to perform a wide range of tasks. A computer system is a nominally complete computer that includes the hardware, operating system (main software), and peripheral equipment needed and used for full operation. This term may also refer to a group of computers that are linked and function together, such as a computer network or computer cluster.
A broad range of industrial and consumer products use computers as control systems. Simple special-purpose devices like microwave ovens and remote controls are included, as are factory devices like industrial robots and computer-aided design, as well as general-purpose devices like personal computers and mobile devices like smartphones. Computers power the Internet, which links billions of other computers and users.
Early computers were meant to be used only for calculations. Simple manual instruments like the abacus have aided people in doing calculations since ancient times. Early in the Industrial Revolution, some mechanical devices were built to automate long, tedious tasks, such as guiding patterns for looms. More sophisticated electrical machines did specialized analog calculations in the early 20th century. The first digital electronic calculating machines were developed during World War II. The first semiconductor transistors in the late 1940s were followed by the silicon-based MOSFET (MOS transistor) and monolithic integrated circuit chip technologies in the late 1950s, leading to the microprocessor and the microcomputer revolution in the 1970s. The speed, power and versatility of computers have been increasing dramatically ever since then, with transistor counts increasing at a rapid pace (as predicted by Moore's law), leading to the Digital Revolution during the late 20th to early 21st centuries.
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
ARRAYS
TYPES OF ARRAYS
MULTIDIMENSIONAL ARRAYS
CHARACTER HANDLING IN C
STRING HANDLING IN C
QUIZ SET 2
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Array
Introduction
One-dimensional array
Multidimensional array
Advantage of Array
Write a C program using arrays that produces the multiplication of two matrices.
An array is a group of data items of same data type that share a common name. Ordinary variables are capable of holding only one value at a time. If we want to store more than one value at a time in a single variable, we use arrays.
An array is a collective name given to a group of similar variables. Each member in the group is referred to by its position in the group.
Arrays are alloted the memory in a strictly contiguous fashion. The simplest array is a one-dimensional array which is a list of variables of same data type. An array of one-dimensional arrays is called a two-dimensional array.
computer dataA computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations (computation) automatically. Modern digital electronic computers can perform generic sets of operations known as programs. These programs enable computers to perform a wide range of tasks. A computer system is a nominally complete computer that includes the hardware, operating system (main software), and peripheral equipment needed and used for full operation. This term may also refer to a group of computers that are linked and function together, such as a computer network or computer cluster.
A broad range of industrial and consumer products use computers as control systems. Simple special-purpose devices like microwave ovens and remote controls are included, as are factory devices like industrial robots and computer-aided design, as well as general-purpose devices like personal computers and mobile devices like smartphones. Computers power the Internet, which links billions of other computers and users.
Early computers were meant to be used only for calculations. Simple manual instruments like the abacus have aided people in doing calculations since ancient times. Early in the Industrial Revolution, some mechanical devices were built to automate long, tedious tasks, such as guiding patterns for looms. More sophisticated electrical machines did specialized analog calculations in the early 20th century. The first digital electronic calculating machines were developed during World War II. The first semiconductor transistors in the late 1940s were followed by the silicon-based MOSFET (MOS transistor) and monolithic integrated circuit chip technologies in the late 1950s, leading to the microprocessor and the microcomputer revolution in the 1970s. The speed, power and versatility of computers have been increasing dramatically ever since then, with transistor counts increasing at a rapid pace (as predicted by Moore's law), leading to the Digital Revolution during the late 20th to early 21st centuries.
The objective of the Level 5 Diploma in Information Technology is to provide learners with an excellent foundation for a career in a range of organisations. It designed to ensure that each learner is ‘business ready’: a confident, independent thinker with a detailed knowledge of Information Technology, and equipped with the skills to adapt rapidly to change.
COURSE TITLE: SOFTWARE DEVELOPMENT VI
COURSE CODE: VIT 351
TOPICS COVERED:
ARRAYS
TYPES OF ARRAYS
MULTIDIMENSIONAL ARRAYS
CHARACTER HANDLING IN C
STRING HANDLING IN C
QUIZ SET 2
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
2. Introduction
● An array is a contiguous group of memory locations that all have the
same type.
● Array can store multiple values of the same type.
● Elements of arrays can be accessed randomly using indices of an array.
5. Array Initialization
In C++, it's possible to initialize an array during declaration.
Example:
int x[6] = {19, 10, 8, 17, 9, 15};
6. Access Elements in C++ Array
Each element in an array is associated with a number. The number is known
as an array index. We can access elements of an array by using those
indices.
Syntax:
array_name[index];
8. Access Elements in C++ Array
● The array indices start with 0. Meaning x[0] is the first element stored
at index 0.
● If the size of an array is n, the last element is stored at index (n-1). In
this example, x[5] is the last element.
● Elements of an array have consecutive addresses. For example,
suppose the starting address of x[0] is 2120d. Then, the address of the
next element x[1] will be 2124d, the address of x[2] will be 2128d and
so on. Here, the size of each element is increased by 4. This is because
the size of int is 4 bytes.
9. Array Declaration without size
● It is possible to declare array without specifying array size, in this way
In such cases, the compiler automatically computes the size.
For Example:
int x[] = {19, 10, 8, 17, 9, 15};
10. Array Declaration without elements
● It is possible to declare array without specifying it’s element
Int x[6]={ }
● In this way In such cases, the compiler will automatically fill the array
elements to 0.
11. Array With Some Empty Members
● In C++, if an array has a size n, we can store upto n number of elements
in the array. However, what will happen if we store less than n number
of elements.
● For example:
int x[6] = {19, 10, 8};
● Here, the array x has a size of 6. However, we have initialized it with
only 3 elements. In such cases, the compiler assigns random values to
the remaining places. Oftentimes, this random value is simply 0.
13. A sample Program to represent the usage of arrays
#include <iostream>
using namespace std;
int main() {
int mark[5] = {19, 10, 8, 17, 9};
//display the value of specific element
cout<<mark[0]<<endl;
//change value of specific element
mark[3] = 9;
// take input from the user
cin >> mark[2];
14. int i=5;
// take input from the user
// insert at ith position
cin >> mark[i-1];
// print ith element of the array
cout<<mark[i-1]<<endl;
//add value of two arrays
cout<<mark[4]+mark[3];
return 0;
}
15. Iterate Array using loop
#include <iostream>
using namespace std;
int main() {
int mark[5] = {19, 10, 8, 17, 9};
for( int i=0;i<5;i++)
{
cout<<mark[i]<<endl;
}
return 0;
}
19
10
8
17
9
OUTPUT
16. For each Loop
● Foreach loop is used to access elements of an array quickly without
performing initialization, testing and increment/decrement.
● The working of foreach loops is to do something for every element
rather than doing something n times.
17. Take input from user in array and show elements of array
#include <iostream>
using namespace std;
int main() {
int arr[5];
for( int i=0;i<5;i++)
{
cout<<"Enter a number:";
cin>>arr[i];
}
18. cout<<"The numbers are:";
for(int num : arr )
{
cout<<num<<endl;
}
return 0;
}
Enter a number:78
Enter a number:90
Enter a number:45
Enter a number:78
Enter a number:34
The numbers are:78
90
45
78
34
OUTPUT
19. Display Sum and Average of Array Elements Using for Loop
#include <iostream>
using namespace std;
int main() {
int numbers[] = {7, 5, 6, 12, 35, 27};
int sum = 0;
int count = 0;
double average;
cout << "The numbers are: ";
for (int n : numbers) {
cout << n << " ";
sum += n;
++count;
The numbers are: 7 5 6 12
35 27
Their Sum = 92
Their Average = 15.3333
OUTPUT
20. }
cout << "nTheir Sum = " << sum << endl;
average = sum /(double) count;
cout << "Their Average = " << average << endl;
return 0;
}
21. Array Out of Bounds
● If we declare an array of size 10, then the array will contain elements
from index 0 to 9.
● However, if we try to access the element at index 10 or more than 10, it
will result in Undefined Behaviour.
22. #include <iostream>
using namespace std;
int main() {
int numbers[] = {7, 5, 6, 12, 35, 27};
for(int i=0;i<10;i++)
{
cout<<numbers[i]<<" ";
}
return 0;
}
7 5 6 12 35 27 1 7
1774496 0
OUTPUT
Write a program that access array element out of bound
23. #include <iostream>
using namespace std;
int main() {
int responces;
int frequency_ctr[11]={0};
for(int i=0;i<40;i++)
{
cout<<"Enter your rating about food from 1-10:";
cin>>responces;
++frequency_ctr[responces];
}
Forty students were asked to rate the quality of the food in the student
cafeteria on a scale of 1 to 10 (1 means awful and 10 means excellent).
Place the 40 responses in an integer array and summarize the results of
the poll.
25. #include <iostream>
using namespace std;
int main() {
int responces;
int frequency_ctr[11]={0};
for(int i=0;i<40;i++)
{
cout<<"Enter your rating about food from 1-10:";
cin>>responces;
++frequency_ctr[responces];
}
cout<<endl<<"RatingtFrequencytBar Chart"<<endl;
Modify the program such that the frequency is represented with
bar chart.
27. #include <iostream>
using namespace std;
int main() {
int i, n, max;
cout << "Enter total number of elements you want to enter: ";
cin >> n;
float arr[n];
cout << endl;
for(i = 0; i < n; ++i) {
cout << "Enter Number " << i + 1 << " : ";
cin >> arr[i];
}
max=arr[0];
Write a program to find the largest element in the array
28. for(i = 1;i < n; ++i) {
if(arr[i]>max)
max = arr[i];
}
cout << endl << "Largest element = "<<max;
return 0;
}
Enter total number of
elements you want to enter:
5
Enter Number 1 : 78
Enter Number 2 : 568
Enter Number 3 : 346
Enter Number 4 : 986
Enter Number 5 : 457
Largest element = 986
OUTPUT
29. Sorting and Searching arrays
● Sorting:
Sorting is a process of placing the data in ascending or descending
order.
● Searching:
The process of finding a particular element of an array is called
searching.
30. Write a program in C++ to find an element in the array using
linear search
#include <iostream>
using namespace std;
# define SIZE 10
int main() {
int arr[10]={12, 67, 34, 89, 23, 45, 90, 123, 456, 32}, i, num;
cout << "Enter a number to search in Array:";
cin >> num;
for(i = 0; i < SIZE; i++){
if(arr[i] == num)
{
Enter a number to search in
Array:90
Element found at index: 6
OUTPUT
31. cout << "Element found at index: " << i;
break;
}
}
if(i == SIZE){
cout << "Element Not Present in Input Array.";
}
return 0;
}
32. Write a program in C++ to sort the array using Bubble sort.
#include <iostream>
using namespace std;
int main()
{
int arr[] = { 12, 11, 13, 5, 6 }, temp, n=5;
for (int pass = 1; pass<n; pass++)
{
for(int i=0; i<n-1;i++)
{
if(arr[i]>arr[i+1])
Sorted array is: 5 6 11 12 13
OUTPUT
34. Multi-Dimensional Array
● Arrays can be used with two dimensions (i.e., subscripts) to represent
tables of values consisting of information arranged in rows and
columns.
● To identify a particular table element, we must specify two subscripts—
the first identifies the element’s row and the second identifies the
element’s column.
35. Multi-Dimensional Array
● The general form of declaring N-dimensional arrays:
data_type array_name[size1][size2]....[sizeN];
data_type: Type of data to be stored in the array.
array_name: Name of the array
size1, size2,... ,sizeN: Sizes of the dimensions
36. 2D Array
● Arrays that require two subscripts to identify a particular element are
called two-dimensional arrays or 2-D arrays.
● Syntax:
data_type array_name[x][y];
● We can find out the total number of elements in the array simply by
multiplying its dimensions:
2 x 4 x 3 = 24
38. 2D Array
● Initializing a 2D Array:
int x[3][4] = {0,1,2,3, 4,5,6,7,8,9,10,11};
int x[3][4] = {{0,1,2,3}, {4,5,6,7}, {8,9,10,11}};
● Accessing a 2D Array:
Elements in Two-Dimensional arrays are accessed using the row
indexes and column indexes.
Example:
x[2][1];
39. 2D Array
● For Example: int a[3][4]={{4,7,8,9},{90,34,50,2},{12,56,87,30}};
Col 0 Col 1 Col 2 Col 3
Row 0 4 7 8 9
Row 1 90 34 50 2
Row 2 12 56 87 30
40. Write a program in C++ to access the element of 2-D array
#include <iostream>
using namespace std;
int main()
{
int x[3][2] = {{0,1}, {2,3}, {4,5}};
for (int i = 0; i < 3; i++)
{
cout<<"Row "<<i<<": ";
for (int j = 0; j < 2; j++)
{
cout<<x[i][j]<<" ";
}
cout<<endl;
}
}
Row 0: 0 1
Row 1: 2 3
Row 2: 4 5
OUTPUT
41. EXERCISE
1. Write a program that take 10 integer inputs from user and store them in an array.
Now, copy all the elements in another array but in reverse order.