Cpp - Calculate yourAge multiply *pAge

Introduction

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

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

Demo

#include <iostream>
  
int main()//from w  w w  .  ja va2  s.  c o 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;
}

Result

Related Exercise