Here's the code with code tags:

Code:

/*Converts coordinates between Cartesian and Polar */
#include <stdio.h>
#include <math.h>
main()
{
FILE *InFile;
FILE *OutFile;
char InFileName[50];
char OutFileName[50];
int cmd;
float x, y, r, theta;
printf("***Welcome to my Coordinate Converting Progam***\n");
printf("Input file name: ");
scanf("%s", InFileName);
printf("Output file name: ");
scanf("%s", OutFileName);
printf("Conversion type: 1=cartesian to polar, 2=polar to cartesian, 3=end program \n");
for (;;) {
printf("Enter command: ");
scanf("%d", &cmd);
switch (cmd) {
case 1:
InFile = fopen(InFileName, "r");
fscanf(InFile, "%f %f", &x, &y);
r = sqrt(x*x+y*y);
theta = atan (y/x);
OutFile = fopen(OutFileName, "w");
fprintf(OutFile, "\n r = %f\n theta = %f", r, theta);
fclose(InFile);
fclose(OutFile);
break;
case 2:
InFile = fopen(InFileName, "r");
fscanf(InFile, "%f %f", &r, &theta);
x = r * cos (theta);
y = r * sin (theta);
OutFile = fopen(OutFileName, "w");
fprintf(OutFile, "\n x = %f\n y = %f", x, y);
fclose(InFile);
fclose(OutFile);
break;
case 3:
printf("Thank you for using Coordinate Converter\n");
return 0;
default:
printf("Please input an option from the menu\n");
printf("Conversion type: 1=cartesian to polar, 2=polar to cartesian, 3=end program \n");
break;
}
}
}