Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Example 2 to display array values and address of an array using pointers

Posted By: Binghamton Fischer     Category: C Programming     Views: 2755

Example 2 to display array values and address of an array using pointers.

Code for Example 2 to display array values and address of an array using pointers in C Programming

#include <stdio.h>
void printarr(int a[][]);
void printdetail(int a[][]);
void print_usingptr(int a[][]);
main()
{
int a[3][2];    \\ A
for(int i = 0;i<3;i++)
 for(int j=0;j<2 ;j++)
 {
{
a[i]=i;
}
}
printdetail(a);
}
void printarr(int a[][])
{
for(int i = 0;i<3;i++)
for(int j=0;j<2;j++)
{
{
printf("value in array %d\n",a[i][j]);
}
}
}
void printdetail(int a[][])
{
for(int i = 0;i<3;i++)
for(int j=0;j<2;j++)
{
{
printf("value in array %d and address is %8u\n",a[i][j],&a[i][j]);
}
}
}
void print_usingptr(int a[][])
{
int *b;    \\ B
b=a;        \\ C
for(int i = 0;i<6;i++)    \\ D
{
printf("value in array %d and address is %16lu\n",*b,b);
b++; // increase by 2 bytes    \\ E
}
}
  
Share: 



Binghamton Fischer
Binghamton Fischer author of Example 2 to display array values and address of an array using pointers is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!