Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In C, to read in data from an external file at file path C: \\Desktop\\my_data.t

ID: 3858650 • Letter: I

Question

In C, to read in data from an external file at file path C: Desktopmy_data.txt to file pointer myfile (assume this has been declared), which statement should be used? myfile = open ("C: \Desktopmy_data.txt", "r"): myfile = fopen("my_data.txt", "r"): myfile = fopent("C: \Desktop\my_data.txt", "r"): myfile = fopen("C: \Desktopmy_data.text", "r"): Assuming an input data file already exists and contains the values given below, what type of looping structure would be best suited to read the data? 5 0.0, 132.5 0.1, 147.2 0.2, 148.3 0.3, 157.3 0.4, 163.2 for do/while while end of file Assuming an input data file already exists and contains the values given below, what type of looping structure would be best suited to read the data? 0.0, 132.5 0.1, 147.2 0.2, 148.3 0.3, 157.3 0.4, 163.2 999.0, -999.0 while for do/while end of file

Explanation / Answer

I c program files file is in local no need to mention the file path simly mention name of the file.

Ex: myfile=fopen(“my_data.txt”,r); in this example copiler understand that file is in current directory. There is no issue for this.

If the file is not there in local directory we have to mention absolute path where the file is located with the following syntax;

myfile=fopen(“c:\desktop\my_data.txt”,r);

So the answer is

Ans: myfile=fopen(“c:\desktop\my_data.txt”,r);

In general we can read data from the data file file content is represented as text mode because it is not the binary file, if it is binary file you can read the data with type of data. But here we are not used binary files just data files so we read the data until end of the file.

Later you can type cast the data as per your requirement

Code may be like this

            Char c;

           fp= fopen(“filename”,”r”);   // fp is file pointer

           while((c=getch(fp))!=EOF)               // condition to check end of file

                  {

                      Putchar( c ); // display the content of file

                 }

          This is the process you have to use.

So Answer is End of file with any terminate conditon

In general we can read data from the data file file content is represented as text mode because it is not the binary file, if it is binary file you can read the data with type of data. But here we are not used binary files just data files so we read the data until end of the file. Later you can type cast the data as per your requirement

Code may be like this

            Char c;

           fp= fopen(“filename”,”r”);   // fp is file pointer

           while((c=getch(fp))!=EOF)    // condition to end of file

                  {

                      Putchar( c ); // display that character

                 }

          This is the process you have to use.

So Answer is End of file with any terminate conditon