Cpp - Calculate yourAge multiply *pAge


The following code show to use point value to do multiplication.

The * operator can be used for multiplication and for dereferencing pAge.


#include <iostream>
int main()/*from  w  ww .j  a  v  a2s  .co  m*/
    unsigned short int myAge = 5, yourAge = 10;
    unsigned short int *pAge = &myAge;  // a pointer
    pAge = &yourAge;       // reassign the pointer
    unsigned short int multAge = yourAge * *pAge;
    std::cout << "\nmultAge:\t" << multAge << "\n";

    return 0;


Related Exercise