Logo 
Search:

C Programming Articles

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

Program to display array values and address of an array using pointers

Posted By: Adalwin Fischer     Category: C Programming     Views: 7712

Write a program to display array values and address of an array using pointers.

Code for Program 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[]);
main()
{
int a[5];
for(int i = 0;i<5;i++)
{
a[i]=i;
}
printdetail(a);
}
void printarr(int a[])
{
for(int i = 0;i<5;i++)
{
printf("value in array %d\n",a[i]);
}
}
void printdetail(int a[])
{
for(int i = 0;i<5;i++)
{
printf("value in array %d and address is %8u\n",a[i],&a[i]);
}
}
void print_usingptr(int a[])
{
int *b;
b=a;        
for(int i = 0;i<5;i++)    
{
printf("value in array %d and address is %16lu\n",*b,b);    \\ D
b=b+2;    
}
}
  
Share: 



Adalwin Fischer
Adalwin Fischer author of Program 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!