Array limit value and an array element address are printed in this program

Data Structure / Array

950

Program:

// in the following program, we can see how an array limit
// value and an array element address are printed


#include<stdio.h>
void printarray(int a[]);
void main()
{
	int a[15];
	int i;
	for( i = 0; i<15; i++)
	{
	a[i] = i;
	}
	printarray(a);
	printdetails(a);
}

void printarray(int a[])
{
	int i;
	for( i = 0; i<15; i++)
	{
	printf("Value in the array %d\n",a[i]);
	}
}

printdetails(int a[])
{
	int i;
	for( i = 0; i<15; i++)
	{
	printf("Value in the array %d  and the address is %u\n",a[i],&a[i]);
	}

}

Output:

Value in the array 0
Value in the array 1
Value in the array 2
Value in the array 3
Value in the array 4
Value in the array 5
Value in the array 6
Value in the array 7
Value in the array 8
Value in the array 9
Value in the array 10
Value in the array 11
Value in the array 12
Value in the array 13
Value in the array 14
Value in the array 0  and the address is 37813988
Value in the array 1  and the address is 37813992
Value in the array 2  and the address is 37813996
Value in the array 3  and the address is 37814000
Value in the array 4  and the address is 37814004
Value in the array 5  and the address is 37814008
Value in the array 6  and the address is 37814012
Value in the array 7  and the address is 37814016
Value in the array 8  and the address is 37814020
Value in the array 9  and the address is 37814024
Value in the array 10  and the address is 37814028
Value in the array 11  and the address is 37814032
Value in the array 12  and the address is 37814036

Explanation:

Array limit value and an array element address are printed in this program

This Particular section is dedicated to Programs only. If you want learn more about Data Structure. Then you can visit below links to get more depth on this subject.