This is a programming quiz. You must use Visual C++. You may not use any notes and you may not start from a preexisting VC++ project (you must only use newly-created files in a newly-created project).
1. Write Knights' Tour for a rectangular board. Query the user for rows and cols. You may always begin the tour at (0,0), and tours may be "open" (in that they do not have to end one move away from 0,0). Output the tour when it is found, plus output the number of calls to placeKnight() along the way.
2. Complete the function approximatePi() in the following code so that it approximates pi via Monte Carlo methods:
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>// returns a random # between 0 and 1 -- your code may need this!
double random1()
{
return (double(rand())/RAND_MAX);
}double approximatePi(int iterations)
{
// you write this code!
}void main()
{
int iterations;while (true)
{
cout << "Enter iterations (<=0 to exit): ";
cin >> iterations;
if (iterations <= 0)
break;
cout << "pi =~ " << approximatePi(iterations) << endl;
}
}