ARRAYS:
An array is a group of related data items that share a common name.For instance,we can define an array name salary to represent a set of
salaries of a group of employees. A particular value is indicated by writing a number called index number of subscript in brackets after the array name.
For example: salary[20];//salary contains maximum of 20 charaters
Array range will be 0 to n.
There are two types of arrays:
1.one dimentional arrays
2.two dimentional arrays
Array declration:
ex: int marks[20];
Entering data in array:
ex: for(i=0;i<=19;i++)
{
printf("\nenter marks");
scanf("%d",&marks[i]);
}
Reading data from an array:
ex: for(i=0;i<=19;i++)
sum=sum+marks[i];
a) An array is a collection of similar elements.
b) The first element in the array is numbered 0,so the element is 1 less than the size of the array.
c) An array is also known as a subscripted variable.
d) Before using an array its type and dimension must be declared.
More on Array(Array Initialisation):
ex: int num[6]={2,4,6,8,10,12};
int n[]={2,3,4,5,6};
float p[]={12.3,34.2};
Note:
a) Till the array elements are not given any specific values,they
are supposed to contain garbage values.
b) If the array is initailsed where it is declared mentioning the dimension of the
array is optional as in the 2nd example above.
Initialising A 2-Dimensional Array:
how to intialise atwo dimensional array?
int stud[4][2];
above initialisation tells that there will be 4 rows and 2 columns.
in other words 4 different numbers of students and thier marks and other thing should be 2 character.
ex: int stud[4][2]={{1234,56},{1345,67},{1456,78},{1567,90}};
it can be written i other form
ex: int stud[4][2]={1234,56,1345,67,1456,78,1567,90};
In Matrix Array is represented as:
ex: int a[3][3];// 3*3 3 rows and 3 columns
Popular Posts
-
The SQL ORDER BY clause comes in handy when you want to sort your SQL result sets by some column(s). For example if you want to select all t...
-
STRINGS: The way a group of integers can be stored in an integer array, similarly a group of characters can be stored in a character array. ...
-
SQL aliases can be used with database tables and with database table columns, depending on task you are performing. SQL column aliases are u...
-
DIFFERENCE BETWEEN STRUCT AND UNION: In structures,each member has its own storage location,whereas all memebers of a union use the same loc...
-
MSDE stands for Microsoft Desktop Engine. MSDE is replaced with Microsoft SQL Server 2005 Express. MSDE is a free, light weight version of S...
-
Declaration of variables In order to use a variable in C++, we must first declare it specifying which data type we want it to be. The syntax...
-
Syntax of JSP Scriptles are: <% //java codes %> JSP Scriptlets begins with <% and ends %> .We can embed any a...
-
Introduction: In this exercise, you are going to build and run a sample Java program called Homework using NetBeans. The sample program can...
-
1 Introducing the .NET Framework with C# The .NET Framework is such a comprehensive platform that it can be a little difficult to descr...
-
A "service" is an application that can start automatically when the computer starts. There are two start up modes: 1. Automatic - ...
No comments:
Post a Comment