By DePaul Dimadis
Choose your prefered Language: greek_flag uk_flag

The Cartesian and Spherical Coordinate System determine the position of a point of the three-dimensional planar space through the sizes () x, y, z and () r, θ, respectively. The transformation from the Cartesian Coordinates () x, y, z to the Spherical () r, θφ is done by the formulas: (co-ordinate type)
Specify a structure named coords to manage material points of mass im of a solid body. The members of the structure are the mass and the three cartesian coordinates () x, y, z, as defined above. All values ​​are double.
A serial file called xyz.txt (to work out the exercise must be created via a text editor or through MS Excel) contains an unknown number of lines that correspond to the material points of a solid body. Each line of the file contains four double values ​​corresponding to the three cartesian coordinates and the mass of a point material (members - data).
Define a matrix of structures of the coords, N-positions (N = known).
The data in the table of structures will be entered by accessing the serial file xyz.txt if the size 𝑟𝑟 resulting from the transformation satisfies the relation: 1.0≤𝑟𝑟≤15.0.
If the number of recordings in the file is greater than the N value then the extra records of the file will not be included in the table of structures.
The following are requested (main () function:
1. Import the data from the xyz.txt file into the table of structures according to the above, checking the existence of the file (see the code below). If the file contains more than N material points, find and display the number of file lines that satisfy condition 1.0≤𝑟𝑟≤15.0 and will not be included in the table of structures. If the file contains fewer than N lines, find and display the number of lines in the file that the structure table will contain.
2. Then find and display the measure of the solid body mass vector vector of the following formula, taking into account all the elements in the table of structures.

FILE * fp;
errno_t err;
if (err = (fopen_s (& fp, filename, mode))! = 0)
printf ("error reading file .... \ n");
exit (1);
else // reading from file