Array is a collection of similar data types. In array we access the value using index.
Declaration of array
Int [ ] marks = new int [5];
Assigning value to the array
int Sum = 0;
For (int i=0; i<= marks. Length; i++)
{
Sum = Sum + marks [i];
}
Response. Write (sum);
Declaration of array
Int [ ] marks = new int [5];
Assigning value to the array
- Marks [0] = 90; Marks[1] = 80;
- Int [ ] marks = new int [ 5 ] { 2, 3,4,5,6 }
- Int [ ] marks = { 2, 3, 4,5, 6,7,8}
int Sum = 0;
For (int i=0; i<= marks. Length; i++)
{
Sum = Sum + marks [i];
}
Response. Write (sum);
Comments
Post a Comment