Assume you have 2D array S[2][4]={{1234,56},
{1212,33},
{1434,80},
{1312,78}};
write a C program to print all the values and their corresponding addresses of this array
using pointers
{1212,33},
{1434,80},
{1312,78}};
write a C program to print all the values and their corresponding addresses of this array
using pointers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "stdio.h" | |
int main() | |
{ | |
int s[4][2] ={ | |
{1234,56}, | |
{1212,33}, | |
{1434,80}, | |
{1312,78} | |
}; | |
int *p=&s[0];// pointer to array | |
for(int i=0;i<=3;i++) | |
{ | |
printf("Start Address of %d th 1-D array = %d\n",i,&s[i]); | |
for(int k=0;k<=1;k++) | |
{ | |
printf("address of elemnt %d in %d th 1-D array %d \t and its value = %d\n",k,i,p,*p); | |
p++; | |
} | |
} | |
return 0; | |
} |
No comments:
Post a Comment