Pointers

Lab C++ Beginner 10 points

Read an integer. Make a pointer to it, triple the value through the pointer, and print the value and whether the pointer is nullptr (true/false).

Input

One integer.

Output

Two lines.

Example

Input

7

Output

21
false
Sample input available Sample output available
Editor
C++

Hints

&x is the address of x; *p accesses it.

nullptr is the C++ null pointer.

Solution explanation

Prefer references when you don't need a pointer's ability to be null or to be re-pointed.

Show solution
#include <iostream>
using namespace std;

int main() {
    int x;
    cin >> x;
    int *p = &x;
    *p *= 3;
    cout << x << "\n" << boolalpha << (p == nullptr) << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD