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
-
Now I will show you how to retrieve the data posted from a HTML file in a JSP page. Consider an html page that prompts the user to enter his...
-
Accessing the Standard CGI Variables: To build the successful web application, you often need to know a lot about the environment in which ...
-
INTRODUCTION TO 'C': C is a programming language developed at AT & T's Bell laboratories of USA in 1972.it was designed by d...
-
SQL aliases can be used with database tables and with database table columns, depending on task you are performing. SQL column aliases are u...
-
Learning about Events (Continue) Lets program the Form_Load event. "MsgBox" is Visual Basic command that launch a message box. for...
-
Steps to follow: 1. Write Person.java as shown below in Code-11.3.a under polypackage directory. (You are welcome to do this work using eit...
-
The Command Button's KeyPress, KeyDown and KeyUp Events The events that will be mentioned in the following pages are commonly used, and ...
-
The SQL AVG aggregate function selects the average value for certain table column. Have a look at the SQL AVG syntax: SELECT AVG(Column1) FR...
-
package interfaceexercise; // Define an interface with three abstract methods. // Any class that implements this interface has to // impleme...
-
We will use the Customers table to illustrate the SQL LIKE clause usage: FirstName LastName Email DOB Phone John Smith John.Smith@yaho...
No comments:
Post a Comment