Question
Write c program. Do part 4 and 5
CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should ha


CH-12 TEXT FILES EXERCISE 12-5 Consider the files grade. txt and letter.txt crated in tho 3 and 4 respectively. Write a progr
CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should have the following format: by Columns 1-4 6-8 number of a student A grade out of 100 EYERCISE 12-4 Write a program that will read the identification numbers of students and their letter grades (A, B, C, D, or F) from the keyboard and store them in a text file named letter.txt. Continue to input until user enters-999 for the identification num- ber. Each record in letter.txt should have the following format: Columns 1-4 Identification number of a student A letter grade 165 C Programming Problem Book/ATILIM-2016
CH-12 TEXT FILES EXERCISE 12-5 Consider the files grade. txt and letter.txt crated in tho 3 and 4 respectively. Write a program that will read these two files line by identfication numbers on the corresponding lines are the same, write it result.txt. The result.txt will have the following format: lerce two files wnite it to another tile r of lir numiz.t ofnumz. txt line and if the to another EXERCISE dentification number of a student A grade A leter grade 1-4 6-8 10 C Programming Problem Book/ATILIM-2016
0 0
Add a comment Improve this question Transcribed image text
Answer #1

12-4 :

#include<stdio.h>
#include<stdlib.h>
int main()
{
   int n;
   char a;
FILE *fp;
fp = fopen("letter.txt","w");

if(fp == NULL)
{
printf("error");   
exit(1);   
}
fprintf(fp,"identification number\tGrade\n");
while(n!=-999)
{
printf("Enter identification number: ");
scanf("%d",&n);

fprintf(fp,"%d\t",num);
printf("Enter Grade: ");
scanf("%c",&a);

fprintf(fp,"%c\n",a);
}
fclose(fp);

return 0;
}

12-5:

#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE *fp1, *fp2, *fresult;
f1 = fopen("grade.txt", "r");
f2 = fopen("letter.txt", "r");

if(f1 == NULL || f2 == NULL)
{
perror("error..!!");
exit(0);
}

fresult = fopen("result.txt", "w");

if(fresult == NULL)
{
perror("error..!! ");
exit(0);
}

while((c=fgetc(f1)) ==fgetc(f2) && c!=EOF )
fputc(c,fresult);

fclose(f1);
fclose(f2);
fclose(fresult);

return 0;
}

Add a comment
Know the answer?
Add Answer to:
Write c program. Do part 4 and 5 CH-12 TEXT FILES SE 12-3 Create a text file named grade.txt that you type yourself by your Each record in grade.txt should have the following format: by Columns...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT