It's all about ARRAYS. Array is a collection of variables of the same data type that is referenced by a common name.
EXAMPLE:
#include
main()
{
int array[4]={25,5,7,11,163};
clrscr();
printf(“%d %d %d %d %d”, array[0], array[1], array[2],array[3],array[4]);
getch();
}
THE OUTPUT FOR THE EXAMPLE IS:
25 5 7 11 163
PARTS OF ARRAY
Array[0] = 25
"Array" is called the array name.
"[0]" is the subscript or index.
"25" is the array element.
* The general form for any declaration is as follows:
type array_name[size]
~> where:
---> type is any valid data type in Turbo C which declares the type of values that array will hold.
---> array_name is a valid variable name which will name the array. It defines how many elements the array will hold.
* The two declarations for arrays number and answer can be combined into a single declaration:
int number[100] , answer [25]
Arrays can give initial values during the declaration. This is called array initialization..
int Array1[5]={25, 5, 7, 11, 163}
No comments:
Post a Comment