Restart Program Function?

Hi, I've created a simple "Distance Calculator" for a game that I play frequently that uses grid/graph points occasionally, basically you tell it two (x, y) coords and it runs the distance formula on them.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* This program is a distance calulator for arma 2/DayZ */


#include "stdafx.h"
#include <iostream>
#include <math.h>


using namespace std;

int main(int argc, char *argv[])
{
    int x1, y1;
    int x2, y2;
    int x1k, y1k;
    int x2k, y2k;
	int km;
	int ad;

	cout << "Choose Unit of Measure 1=Km, 2=M ", cin >> km;
	if (km == 1) {
	cout << "You've Chosen Kilometers." << endl;
	cout << "Enter X1 = ", cin >> x1k;
    cout << "Enter Y1 = ", cin >> y1k;
    cout << "Enter X2 = ", cin >> x2k;
    cout << "Enter Y2 = ", cin >> y2k;
    cout << "Distance From (" << x1k << ", " << y1k << ") to (" << x2k << ", " << y2k << ") = " << (sqrt(pow(((x2k - x1k)/2.00), 2.00) + pow(((y2k - y1k)/2.00), 2)))/5.00 << "km" << endl;
	system ("PAUSE");
	} else {
	cout << "You've Chosen Meters." << endl;
	cout << "Enter X1 = ", cin >> x1;
    cout << "Enter Y1 = ", cin >> y1;
    cout << "Enter X2 = ", cin >> x2;
    cout << "Enter Y2 = ", cin >> y2;
    cout << "Distance From (" << x1 << ", " << y1 << ") to (" << x2 << ", " << y2 << ") = " << ((sqrt(pow(((x2 - x1)/2.00), 2.00) + pow(((y2 - y1)/2.00), 2.00)))/5.00)*1000.00 << "m" <<endl;
	system ("PAUSE");
	}
	cout << "Would you like to find another distance? (1=Yes, 2=No) ", cin >> ad;
	if (ad == 1) {
	
	}
	return 0;

}

Anyway, as you may have noticed, at the end there, there is an empty space,

cout << "Would you like to find another distance? (1=Yes, 2=No) ", cin >> ad;
if (ad == 1) {

}


and as mentioned in the title of this thread, I am asking if there is a way that, if the user enters 1 to restart and find another distance it will start the program from the top of the script.
All help is appreciated, thanks in advance!
~Michael
What you are looking for would be a loop.

You can learn about them here: http://www.cplusplus.com/doc/tutorial/control/

Just put whatever code you need to repeat within a loop.
thanks that did the trick!
Topic archived. No new replies allowed.