Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. void test()
  4. {
  5.     int f=23;
  6.     float c=435.5;
  7.     double e=3.01;
  8.     int a[2][3]={
  9.         {1,2,3},
  10.         {1,2,3}
  11.     }, row=2,col=3;
  12.     char *s="Hello";
  13.     bool boo=false;
  14.     cout<<"Using a[i][j]"<<endl;
  15.     for(int i=0;i<row;++i)
  16.     {
  17.         for(int j=0;j<col;++j)
  18.             cout<<"Val: "<<a[i][j]<<" Add: "<<&a[i][j]<<" "; //Print the address of each element in array
  19.         cout<<endl;
  20.     }
  21.     cout<<endl;
  22.     cout<<"Using a[0][i]"<<endl;
  23.     for(i=0;i<row*col;++i)
  24.     {
  25.         cout<<"Val: "<<a[0][i]<<" Add: "<<&a[0][i]<<" "; //How can it be ?
  26.         if((i+1)%col==0) cout<<endl;
  27.     }
  28. }
  29. int main()
  30. {
  31.     test();
  32.     system("pause");
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement