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

can this be answered in C code please. and if you use code blocks to run it. It

ID: 3821928 • Letter: C

Question

can this be answered in C code please. and if you use code blocks to run it. It really helps me try to find my mistakes thanks.

2. File Q.ixt contains a questionnaire (one question per line). File A.txt contains a user's answers to this questionnaire. Combine these to files into a single file QA.txt, so that each question is followed by the respective answer, as in the example below. Be sure to test for possible read/write errors. u Q.txt Notepad A tot Notepad Eile Edit Format View Help Eile Edit Format View Help Is PENG awesome? Absolutely! What is your favorite color? Green How long is one foot? It's exactly one foot lon What is your address? 123 Main St., Middle Carolina. a QA tot Notepad Eile Edit Format View Help IS awesome? Absolutely! your favorite color? Green How long is one foot? It's exactly one foot long. What is your address? 123 Main St., Middle Carolina

Explanation / Answer

#include <stdio.h>

public static void main() {
FILE *file1,*file2,*file3;
   char q,a,qa;
file1 = fopen("/LOCATION/Q.txt", "r");
file2 = fopen("/LOCATION/A.txt", "r");
file3 = fopen("/LOCATION/QA.txt", "w");
   if( file1 == NULL || file2==NULL )
{
perror("FILE NOT FOUND OR ERROR IN FILES ");
exit(EXIT_FAILURE);
}

printf("The contents of %s file are : ", file_name);

while( ( q = fgetc(file1) ) != EOF && ( a = fgetc(file2) ) != EOF)
{
   fprintf(file3,q);
   fprintf(file3,a)
   }

fclose(file1);
fclose(file2);
fclose(file3);  
}

In this program we first check whether there is data in files and whether the files located at particular location.

Than read one by one from both files and write into third file.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote