C Program using concept of Pointer and Array with source code

C Program using concept of Pointer and Array with source code - blurnooz.com

The concept of Pointer and Array in C programming language. Get the full source code of C program with proper output. It’s unique and easy to understand and End of Article Download Link is Available.

Write a program which uses concepts of pointer and array.

#include
#include
void main()
{
	int a[10],n,i;
	clrscr();
	printf("Enter n:");
	scanf("%d",&n);
	printf("Enter elements of array:\n");
	for(i=0;i<n;i++)
	{
		printf("Enter element %d:",i);
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		printf("\nElement at a[%d] is %d.\n",i,a[i]);
		printf("Element at a[%d] is %d.\n",i,*(a+i));
		printf("Element at a[%d] is %d.\n",i,*(i+a));
		printf("Element at a[%d] is %d.\n",i,i[a]);
		printf("Address of the element at a[%d] is %u.\n",i,(a+i));
	}
	getch();
}

 

Output :-

Enter n:5
Enter elements of array:
Enter element 0:9
Enter element 1:8
Enter element 2:7
Enter element 3:6
Enter element 4:5

Element at a[0] is 9.
Element at a[0] is 9.
Element at a[0] is 9.
Element at a[0] is 9.
Address of the element at a[0] is 65504.

Element at a[1] is 8.
Element at a[1] is 8.
Element at a[1] is 8.
Element at a[1] is 8.
Address of the element at a[1] is 65506.

Element at a[2] is 7.
Element at a[2] is 7.
Element at a[2] is 7.
Element at a[2] is 7.
Address of the element at a[2] is 65508.

Element at a[3] is 6.
Element at a[3] is 6.
Element at a[3] is 6.
Element at a[3] is 6.
Address of the element at a[3] is 65510.

Element at a[4] is 5.
Element at a[4] is 5.
Element at a[4] is 5.
Element at a[4] is 5.
Address of the element at a[4] is 65512.

Leave a Reply

Please enter your comment!
Please enter your name here

*