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

Need hlp with the following questions? Question1 Write the code to do the follow

ID: 3916037 • Letter: N

Question

Need hlp with the following questions?

Question1 Write the code to do the following: open the input file named as data.txt, read one line from input file data.txt display that line on the screen close the file Question2 Write the code to do the following: -read input from the keyboard by displaying the message on the screen to ask and read the following information: *name of student * student id score1, score2, score3 open output file studentGrade.txt to write Write to the output file studentGrade.txt the following information: For example: close file Name of student- student id - score1, score2, score3-average James Smith-0097765-98.50, 87.00, 78.25-87.92 Question 3 Write the code to do the following: open the file input.txt that contains several lines Open file input.txt to read -read a line then display on the screen continue read and display on the screen all the lines until end of the file Write:"End of the filee input.txt" on the screen close input.txt file

Explanation / Answer

Question 1:

#include<stdio.h>

int main()
{
int i;

char c;
FILE *fp1; //Initialisation of file pointer

fp1=fopen("input file data.txt","r"); //Reading the file input file data.txt
do
{
c=getc(fp1); //Scanning each character
printf("%c",c); // Printing on console
}while(c!=' '); // Condition for end of line
fclose(fp1); // Closing the file
return 0;
}

Question 2:

#include<stdio.h>

int main()
{
int i;
char name[20],studentid[10];
float score1,score2,score3;
FILE *fp1; //Initialisation of file pointer
printf("Enter the name of the student"); // Taking inputs from the console
scanf("%s",&name);
printf("Enter the ID of the student");
scanf("%s",&studentid);
printf("Enter the score1 of the student");
scanf("%f",&score1);
printf("Enter the score2 of the student");
scanf("%f",&score2);
printf("Enter the score3 of the student");
scanf("%f",&score3);
fp1=fopen("student grade.txt","w");
fprintf(fp1,"%s-%s-%f-%f-%f",name,studentid,score1,score2,score3); // Writing into the file student grade.txt
fclose(fp1); // Closing the file

return 0;
}

Question 3:

#include<stdio.h>

int main()
{
int i;
char c;
FILE *fp1; //Initialisation of file pointer

fp1=fopen("input.txt","r"); //Reading the file input.txt
do
{
c=getc(fp1); //Scanning each character
printf("%c",c); // Printing each character on console
}while(c!=EOF); //condition for checking end of the file
printf(" End of the file input.txt");
fclose(fp1); //closing the file input .txt
return 0;
}

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