The document discusses arrays in C programming language. It defines arrays as fixed-sized sequenced collections of elements of the same data type that share a common name. One-dimensional arrays represent lists, while two-dimensional arrays represent tables with rows and columns. Arrays must be declared before use with the size specified. Elements can be accessed using indices and initialized. Common operations like input, output, sorting and searching of array elements are demonstrated through examples.
Array
Introduction
One-dimensional array
Multidimensional array
Advantage of Array
Write a C program using arrays that produces the multiplication of two matrices.
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
An array is a very important derived data type in the C programming language. This presentation contains basic things about arrays like definition, initialization, their types, and examples.
Array
Introduction
One-dimensional array
Multidimensional array
Advantage of Array
Write a C program using arrays that produces the multiplication of two matrices.
This is a presentation on Arrays, one of the most important topics on Data Structures and algorithms. Anyone who is new to DSA or wants to have a theoretical understanding of the same can refer to it :D
2D array in C++ language ,define the concept of c++ Two-Dimensional array .with example .and also Accessing Array Components concept.and Processing Two-Dimensional Arrays.
An array is a very important derived data type in the C programming language. This presentation contains basic things about arrays like definition, initialization, their types, and examples.
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.
C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language. This lecture series will give you basic concepts of structured programming language with C.
Introduction of arrays, Declaration of array, Initialization of array, Sorting, Multidimensional array. Some code examples that will make you clear about the concept of arrays.
https://github.com/ashim888/csit-c
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.
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Embracing GenAI - A Strategic ImperativePeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
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.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
2. • We have used the fundamental data types, char,
int, float, double.
• These types are constrained by the fact that a
variable of these types can store only one value at
any given time
• In many applications, we need to handle large
volumes of data
• To process such large amounts of data, we need a
powerful data types that would facilitate efficient
storing, accessing and manipulation of data items
3. • C supports a derived data type known as array.
• An array is a fixed-sized sequenced collection of
elements of the same data type thats shares a
common name.
• The common name a is the array name and each
individual data item is known as an element of the
array.
• The elements of the array are stored in the
subsequent memory locations starting from the
memory location given by the array name.
4. Array can be classified as two types are,
1. One-Dimensional Array
2. Two-Dimensional or multidimensional
Array
5. One-Dimensional Array
◦ A one-dimensional array can be used to represent a
list of data items. It is also known as a vector.
Two-Dimensional Array
◦ A two dimensional array can be used to represent a
table of data items consisting of rows and columns.
It is also known as a matrix
6. Every array must be declared before use like other
variables.
The declarations of one-dimensional and
multidimensional arrays differ slightly.
Declaration of One-dimensional array:
where
data_type refers to the data type of elements in the array.
It can be a primitive or derived data type.
name is an identifier which represents the array name.
size is an integer expression representing the total
number of elements in the array.
data_type name1[size1], name2[size2],…, namen[sizen];
7. The base address of an array is the address of the
zeroth element (starting element) of that array.
When an array is declared, the compiler allocates a base
address and reserves enough space in memory for all
the elements of the array.
In C, the array name represents this base address.
For example, float x[5]; is the declaration of a one-
dimensional array.
It defines a float array x of size 5 that represents a
block of 5 consecutive storage regions.
8. Each element in the array is referred to by the array
variables x[0], x[1], x[2] ,x[3] and x[4] where 0,1,2,3
and 4 represent subscripts or indices of the array.
In general, x[i] refers to the ith element of the array.
The array subscripts always start at zero in C and
they are integer expressions.
Hence, x[0] refers to the starting element, x[1] refers
to the next element and x[4] refers to the last
element.
The declaration double list[10], array[15]; declares
two arrays, named list and array having 10 and 15
elements respectively of double precision data type.
9. The elements of an array may be assigned with the values using
initialisation instead of reading them by the I/O functions.
An array can be initialised in its declaration only.
The list of initialisers (values) are enclosed in braces.
The initialisers are separated by commas and they must be
constants or constant expressions.
One-dimensional array can be initialised as given below.
int a[4]={3,5, -8, 10};
The values within the braces are scanned from left end and
assigned to a[0], a[1] and so on.
A semicolon should be placed after the closing brace.
10. “For “ loops used extensively for array processing
Example 1: write a program to read an array and
print.
#include<stdio.h>
void main()
{
int i,a[10];
for(i=0;i<10;i++)
scanf(“%d”,&a[i]);
for(i=0;i<10;i++)
Printf(“n %d”,a[i]);
}
11.
12. #include<stdio.h>
void main()
{
int x[2],i;
printf("nEnter the inputs:");
for(i=0;i<2;i++)
scanf("%d",&x[i]);
for(i=0;i<2;i++)
printf("nThe value in x[%d] is %d",i,x[i]);
}
OUTPUT:
Enter the inputs:3
6
The value in x[0] is 3
The value in x[1] is 6
13. /*Determines the length of a message */
#include<stdio.h>
main()
{
char ch;
int len=0;
printf(“Enter a message : ”);
ch=getchar();
while (ch!=‘n’) {
len++;
ch=getchar();
}
printf(“Your message was %d character(s) long. n”,
len);
return 0;
}
14. The c languages treats strings as arrays of characters
The compiler terminates the character strings with an
additional null (‘0’) character.
String is a one dimensional array of characters in c.
The element name[10] holds the null character ‘0’ at
the end
When declaring character arrays, we must always allow
one extra elements space for the null terminator
16. There are different way to initialize a character array variable.
char name[10]=“StudingTonight”; //valid initialization
char name[10]={‘L’,’E’,’S’,’S’,’O’,’N’,’S’,’0’}; // valid Init
Some example for illegal Initialization of character array are,
char ch[3]=“hello”; // Illegal
char str[4];
str=“hello”; //illegal
17. Format:
data_type array_name[row_size1][column_size1];
The first subscript represents the row size and the second subscript
represents the column size.
The value in the ith row and jth column is referred to by name[i][j].
The total number of elements in a two dimensional array is calculated
by multiplying the number of rows by the number of columns.
In two-dimensional arrays, the values are stored row by row.
19. For example, the declaration int a[3][2] ,b[7][4]; defines
the two-dimensional integer arrays a and b.
These arrays are arrays of integer arrays.
Six (rows * columns) elements of a are stored row by row
in the consecutive memory locations.
This method of storing the elements in the memory is
known as row major order storage representation
The zeroth element of array a is denoted by a[0][0] and the
last element in that array is denoted by a[2][1].
Similarly, for the array b, the zeroth element and the last
element are represented by b[0][0] and b[6][3] respectively.
21. Syntax:
data_type array_name[row_size][col_size]={variables};
A two-dimensional array can be initialised as given below.
int a[3][2] = {20, 25, -3, 8, -5, 7};
Here, the initialised values are assigned to the array elements
according to the order of the storage in the memory.
But if the initialisers are enclosed within the inner braces as given
below
int a[3][2] = {{20,25}, {-3, 8}, {-5,7}};
The initialised values within the inner braces are assigned to each row.
To enforce the assignment of each row, it is essential to use the inner
braces.
22. If the number of values initialised for an array is less than the size
mentioned, the missing elements are assigned zero. In the initialisation
int a[3][4] = { {1,2},{4,8,15} };
the elements a[0][0] and a[0][1] of the zeroth row and a[1][0], a[1][1] and
a[1][2] of the first row are initialised with the values 1,2,4,8 and 15
respectively.
All the other elements are initialised to zero.
If it is given as
int a[3][4] = {1,2,3,8,15};
the values are assigned from the left end to a[0][0], a[0][1], a[0][2],
a[0][3], and a[[1][0] according to the order of the storage representation.
If the number of initialisers exceeds the size of the array, it is an error.
23. The size of a one-dimensional array need not be mentioned in its
initialisation.
In this case, the compiler will count the values assigned and take it
as the size of that array.
In multidimensional arrays the leftmost subscript may be omitted
and all the others must be specified. The initialisation
int x[ ] = {2,4,6,8,10};
makes the array x having 5 elements
float a[ ][2] = {{3.2,4.8}, {5.3,3.7}};
makes the array a having 2 rows and 2 columns.
24. #include<stdio.h>
void main()
{
int i,j;
int x[2][2]={ {1,50},
{2,75}
};
for(i=0;i<2;i++)
for(j=0;j<2;j++)
printf("nThe value in x[%d][%d] is %d",i,j,x[i][j]);
}
OUTPUT:
The value in x[0][0] is 1
The value in x[0][1] is 50
The value in x[1][0] is 2
The value in x[1][1] is 75
25. #include<stdio.h>
void main()
{
int i,j;
int x[][2]={ {1,50},{2,75},{3,65}};
for(i=0;i<=2;i++)
for(j=0;j<2;j++)
printf("nThe value in x[%d][%d] is %d",i,j,x[i][j]);
}
OUTPUT:
The value in x[0][0] is 1
The value in x[0][1] is 50
The value in x[1][0] is 2
The value in x[1][1] is 75
The value in x[2][0] is 3
The value in x[2][1] is 65
26. /* PROGRAM TO FIND THE MINIMUM VALUE AND ITS POSITION */
#include<stdio.h>
#define MAX 5
main( )
{
int a[MAX],i,min;
int pos = 0; /* Fixing position if the first number is
the minimum value */
printf("Enter the array elementsn");
for(i=0;i<MAX;i++)
scanf("%d",&a[i]);
min=a[0];
for(i=1;i<MAX;i++)
if(a[i] < min)
{
min=a[i];
pos=i; /* Fixing the minimum value position*/
}
printf(“ MINIMUM VALUE = %dn”,min);
printf(“ POSITION = %dn”,pos);
}
SAMPLE INPUT AND OUTPUT
Enter the array elements
14 29 37 25 45
MINIMUM VALUE = 14
POSITION = 0
27. #define MAXROW 2
#define MAXCOL 4
main( )
{
int s[MAXROW][MAXCOL],t[MAXCOL][MAXROW];
int i,j;
printf("Enter the values of the matrixn");
for(i=0;i<MAXROW;i++)
for(j=0;j<MAXCOL;j++)
scanf("%d",&s[i][j]);
printf("nGiven Matrixnn");
for(i=0;i<MAXROW;i++)
{
for(j=0;j<MAXCOL;j++)
printf("%dt",s[i][j]);
printf("n");
}
28. for(i=0;i<MAXCOL;i++)
for(j=0;j<MAXROW;j++)
t[i][j] = s[j][i];
printf("nTranspose of the matrixnn");
for(i=0;i<MAXCOL;i++)
{
for(j=0;j<MAXROW;j++)
printf("%dt",t[i][j]); printf("n");
}
}
SAMPLE INPUT AND OUTPUT
Enter the values of the matrix
10 20 30 40 50 60 70 80
Given Matrix
10 20 30 40
50 60 70 80
Transpose of the matrix
10 50
20 60
30 70
40 80
29. #include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,r1,r2,c1,c2;
int a[5][5],b[5][5],c[5][5];
clrscr();
//step1:
printf("n Enter the size of matrix
A:");
scanf("%d%d",&r1,&c1);
printf("n Enter the size of matrix
B: ");
scanf("%d%d",&r2,&c2);
if((c1==c2)&&(r1==r2))
goto step2;
else
goto step1;
//step2:
printf("n Enter the elements of matrix
A n");
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
scanf("%d",&a[i][j]);
}
}
printf("n Enter the elements of matrix
B n");
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
scanf("t%d",&b[i][j]);
}
}
31. /* PROGRAM TO REMOVE THE DUPLICATE ELEMENTS IN AN ARRAY */
#define MAX 5
main( )
{
int a[MAX];
int i,j,k,n=MAX,p;
for(i=0;i<n;i++)
{
printf("Enter the value of a[%d]:n",i);
scanf("%d",&a[i]);
}
printf("Array before deleting duplicate elementsn");
for(i=0;i<n;i++)
printf("%dt",a[i]);
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
32.
{
if(a[i] == a[j])
{
p = i ;
for(k=j;k<n;k++)
a[k] =a[++j];
j = p; n--;
}
}
}
putchar('n');
printf("Array after deleting duplicate elementsn");
for(i=0;i<n;i++)
printf("%dt",a[i]);
putchar('n');
}
SAMPLE INPUT AND OUTPUT
Enter the value of a[0]:
5
Enter the value of a[1]:
8
Enter the value of a[2]:
5
Enter the value of a[3]:
12
Enter the value of a[4]:
8
Array before deleting duplicate elements
5 8 5 12
8
Array after deleting duplicate elements
5 8 12
33. /* PROGRAM TO SORT AN ARRAY */
#define MAX 5
main( )
{
int a[MAX],i,j,temp;
printf("Enter the array elementsn");
for(i=0;i<MAX;i++)
scanf("%d",&a[i]);
for(i=0;i<MAX;i++)
for(j=i+1;j<MAX;j++)
{
if(a[i] >a[j])
Example Programs
34. {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
printf("nAscending ordern");
for(i=0;i<MAX;i++)
printf("%dt",a[i]);
printf("nDescending ordern");
for(i=MAX-1;i>=0;i--)
printf("%dt",a[i]);
}
SAMPLE INPUT AND OUTPUT
Enter the array elements
11 15 20 45 15
Ascending order
11 15 15 20 45
Descending order
45 20 15 15 11
Example Programs
35. /*PROGRAM TO CONVERT A 2-D ARRAY TO 1-D ARRAY */
#define MAXROW 3
#define MAXCOL 2
main( )
{
int a[MAXROW][MAXCOL],b[MAXROW*MAXCOL];
int i,j,k=0;
printf("Enter the matrix elements in row ordern");
for(i=0;i<MAXROW;i++)
for(j=0;j<MAXCOL;j++)
{
scanf("%d",&a[i][j]);
Example Programs
36. b[k++] = a[i][j];
}
printf("Given two-dimensional arrayn");
for(i=0;i<MAXROW;i++)
{
for(j=0;j<MAXCOL;j++)
printf("%dt",a[i][j]);
printf("n");
}
printf("Equivalent one-dimensional arrayn");
for(i=0;i<MAXROW*MAXCOL;i++)
printf("%dt",b[i]);
}
SAMPLE INPUT AND OUTPUT
Enter the matrix elements in row order
10 15 20 25 30 35
Given two-dimensional array
10 15
20 25
30 35
Equivalent one-dimensional array
10 15 20 25 30 35
Example Programs