you write this code for me in c ++ language? #include int main() { /* to have both the files */ FILE *g1; FILE *g2; /* ooening both the files in read mode */ g1=fopen("group1.txt","r"); g2=fopen("group2.txt","r"); char c[10][10]; char c1[10][10]; int cc=0,cc1=0; int num1[10][20],num2[10][20];

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Can you write this code for me in c ++ language?

#include <stdio.h>

int main()

{

/* to have both the files */

FILE *g1;

FILE *g2;

/* ooening both the files in read mode */

g1=fopen("group1.txt","r");

g2=fopen("group2.txt","r");

char c[10][10];

char c1[10][10];

int cc=0,cc1=0;

int num1[10][20],num2[10][20];

/* getting the first string */

fscanf(g1,"%s",c[cc]);

float sum1[10],sum2[10];

/* to store the sum of score of each subject */

for(int i=0;i<5;i++)

{

sum1[i]=0;

sum2[i]=0;

}

int p1=0,p2=0;

/* processing the data in the first file */

while(1)

{

int num1;

fscanf(g1,"%d",&num1);

p1++;

if(num1==-999)

{

p1--;

sum1[cc]=sum1[cc]/p1;

cc++;

if(cc==5)

break;

fscanf(g1,"%s",c[cc]);

p1=0;

continue;

}

sum1[cc]+=num1;

}

 

fscanf(g2,"%s",c1[cc1]);

/* processing the data in the second file */

while(1)

{

int num2;

fscanf(g2,"%d",&num2);

p2++;

if(num2==-999)

{

p2--;

sum2[cc1]=sum2[cc1]/p2;

cc1++;

if(cc1==5)

break;

fscanf(g2,"%s",c1[cc1]);

p2=0;

continue;

}

sum2[cc1]+=num2;

}

/* printing the result in the proper format */

printf("Course Course 0 10 20 30 40 50");

printf(" 60 70 80 90 100\n");

printf("ID Average ");

printf("|....|....|....|....|....|....|....|....|....");

printf("|....|\n");

for(int i=0;i<5;i++)

{

printf("%s %.2f ",c[i],sum1[i]);

int p1=sum1[i]/2;

int p2=sum2[i]/2;

for(int i=0;i<(p1);i++)

printf("*");

printf("\n");

printf(" %.2f ",sum2[i]);

for(int i=0;i<(p2);i++)

printf("#");

printf("\n\n");

}

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY