Array (single dimensional array) :
An array is a group of elements of same data types.
This program will accept 5 subject marks and it will store them into an array “m” and then it will calculate the total. Array always start from 0(zero).
#include<iostream.h> #include<conio.h> void main() { clrscr(); int tot=0; int m[5]; //array declaration for (int i=0; i <=4; i++) { cout << " Enter any number:"; cin >> m[i]; tot = tot + m[i]; } cout << "The total is =" << tot; getch(); } Output is-> Enter any number: 55 Enter any number: 76 Enter any number: 85 Enter any number: 93 Enter any number: 68 The total is = 377