Guest User

Untitled

a guest
Nov 25th, 2018
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     double arr[10];
  7.     for(int i=0; i<10; i++) arr[i] = i + 5.6;
  8.     cout << "test loop: arr[0], arr[1] = " << arr[0] << ", " << arr[1] << endl << endl;
  9.  
  10.     printf("addr of arr[9] is: %p\n", &arr[9]);             // if the result is addr
  11.     cout << "value of *(arr+4) is: " << *(arr+4) << endl;   // expected result is 9.6
  12.     printf("addr of (arr+1) is: %p\n", arr+1);              // expected result is addr-64
  13.  
  14.     // another test case
  15.     int num[10];
  16.     for(int i=0; i<10; i++) num[i] = i * 2;
  17.     printf("\nthe result of *num + 7, *(num+7) = %d, %d", *num + 7, *(num+7));    // expected result is 7, 14
  18. }
Add Comment
Please, Sign In to add comment