Professional Documents
Culture Documents
Cpe102 HW11 PDF
Cpe102 HW11 PDF
Cpe102 HW11 PDF
COMPUTER ENGINEERING
CHIANG MAI UNIVERSITY
CPE102 Computer Programming
Homework 11
);
);
);
);
);
return 0;
}
a[0]*a[0]
a[1]*a[1]
a[2]*a[2]
a[3]*a[3]
a[4]*a[4]
=
=
=
=
=
1
4
9
16
25
2. ( Run )
Source Code
#include <iostream>
using namespace std;
int main()
{
int a = 2;
int b[] = {10,12,25,31,15};
int *c = &a;
int *d = b;
int **e = &c;
cout << *(a+d) << ;
cout << *d++ << ;
cout << *d << ;
cout << (*c)++ << ;
cout << *c << ;
cout << **e << ;
return 0;
}
3. ( Run )
Source Code
#include <iostream>
using namespace std;
int main()
{
int a = 2, b = 4, c = 10;
int *d = &a, *e = &b;
int * &f = d;
*d *= 3;
f = &c;
*e = *d + a;
cout << a << " ";
cout << b << " ";
cout << c << " ";
return 0;
}