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

COMPILERS PROGRAM TRANSLATION Assume you need an application that operates on tw

ID: 667407 • Letter: C

Question

COMPILERS

PROGRAM TRANSLATION

Assume you need an application that operates on two kinds of data types D1 and D2. Both D1 and D2 need to be defined with typedef.

Assume you need some functions to operate on the data (assuming the C langauge): f1D1() and f2D1() operating on D1 and f1D2() operating on D2.

Assume a helper function fhD1() and helper integer intD1 to help the functions operating on D1 (not available to others).

Assume global data g1 and g2 of some built in type.

Assume the main created a variable of type D1 and then operates on it. D2 is not needed in main, but it is needed in f1D2().

Given this, and disregarding other details, design all files needed. Use inclusion-prevention. For each file you have, show important elements, disregarding other details. Submit as actual files with the actual names.

Explanation / Answer

Hi,

Below is the solution to your question:

#include<stdio.h>
#include<conio.h>
#include<string.h>

//Global variables//

int average_marks;
int sum;

//First datatype for student//

typedef struct student {
char name[50];
int marks;
} stud;

//Second datatype for books//

typedef struct books {
   char bname[100];
   int ssn;
   int pages;
}book;
//Function operating on datatype 2 books//
int book_details{
   book b1;
   printf("Enter the book details ");
   book b1 = {"Let Us C",1000,90};
   printf(" Name of Book : %s",b1.bname);
printf(" SSN of Book : %d",b1.ssn);
printf(" Pages in Book : %d",b1.pages);
return(0)
  
}

void main() {
stud s1[50];
printf(" Enter student record ");
int n,average_marks;
printf("Enter the number of students ");
scanf(%d,&n);
   for (int i=0;i<n;i++){
printf(" Student name : ");
scanf("%s", s1[i].name);
printf(" Enter student marks : ");
scanf("%d", &s1[i].marks);
printf(" Student name is %s", s1[i].name);
printf(" Roll is %d", s1[i].marks);
getch();
       int sum=sum+s1[i].marks;
       average_marks=sum/n;
   }
   printf("Average marks of all students=%d ",average_marks);  
  
printf("Now printing book details.... ");
book_details();
  
}

Explaination:

1.I have declared two variables average_marks,sum as global varaibles.

2.I have created 2 different datatypes using typedef

   a.Student

   b.Books

3.I have created a method to display the book details as book_details outside the main.

4.Finally created a main method that displays the average marks of all the students using the structure datatype of student created previously and calls the book_details method also in main.

Hope that helps..HAPPY ANSWERING!!!!!!

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