A friend has been helping me but he only knows C++ so he used C++ commands, I just want to know if the code is correct so i can then change the commands to C.

I test it and it ask me to enter the values for A1, A2,....then when i click enter so it can give the distance between the points, it doesn't do it.

Suppose two men (say, A and B) walk away from the same location as follows.

Man A walks

A1 miles to east, then

A2 miles to north-east, then

A3 miles to east again and stops.

Man B walks

B1 miles south, then

B2 miles west, then

B3 miles south-west, and stops

We want to know the straight line distance between the two points where these men stopped. Solve the problem in terms of A1, A2, A3, B1, B2, B3 (user will enter values for these variables) and then write a program to compute the straight line distance between Man A and Man B.

Code:

#include <iostream>
#include <math.h>
using std:: cout;
using std:: cin;
using std:: endl;
int main ()
{
int A1, A2, A3, B1, B2, B3;
cout<<"Enter A1: ";
cin>>A1;
cout<<"Enter A2: ";
cin>>A2;
cout<<"Enter A3: ";
cin>>A3;
cout<<"Enter B1: ";
cin>>B1;
cout<<"Enter B2: ";
cin>>B2;
cout<<"Enter B3: ";
cin>>B3;
double A2X = sqrt(pow((double)A2,2)/2);
double B3X = sqrt(pow((double)B3,2)/2);
double X, Y;
X = A1 + A3 + B2 + A2X + B3X;
Y = A2X + B3X;
X = pow(X, 2);
Y = pow(Y, 2);
double ans = sqrt(X + Y);
cout<<printf("\nThe answer is: %d", ans);
}