#include <iostream>
using namespace std;
void printValue(int * ptr) {
if (ptr != nullptr) {
cout << "Value:0 " << * ptr << endl;
} else {
}
}
int main() {
int * number = nullptr; // Pointer is null initially
printValue(number); // This should print the value pointed to by the pointer
return 0;
}
Add Items to a Favorite Places List
In this task, you will create an empty list to store your favorite places and allow the user to append elements dynamically using the append() method.
Input Format
The first line contains a single integer n, representing the number of places to add.
The next n lines each contain the name of a favorite place to insert into the list.
Output Format
Favorite places list: ['list data']
Sample 1:
Input
Output
3 Paris New York Tokyo
Final list: [‘Paris’, ‘New York’, ‘Tokyo’] please solution