Please tell me how to take input int this

PLease help in the following ques

You can build the tree like this

Node* buildTree() {
	int rt, child;
	cin >> rt >> child;
	Node *root = new Node (rt);
	if (child == 0)
		return root;

	root->left = buildTree();
	if (child == 2)
		root->right = buildTree();

	return root;
}

Logic to find sum at level k

  1. use a level variable to determine the level of current node
  2. call on left and right part of tree and store ans of both part
    return the sum of both ans
  3. if current level is equal to k return root->data ( value of node)

Complete Reference Code