Question

In: Computer Science

Using C language The system that you will develop holds the personal information for a number...

Using C language

The system that you will develop holds the personal information for a number of students and the information of the course each student is registered in. The assumption is that each student is registered in a single course only. But the system will have a number of students saved.

REQUIREMENTS:

In this lab, you will introduce a simple student records system, which will save the student information as well as a single course that the student is registered in. Firstly, the system should ask the user to enter the number of students they wish to save. Then the system should start asking the user to enter each student and course information. Keep in mind that the student information is to be presented in a struct, called Student, while the course information is presented in another struct, called Course. The Student struct will have a pointer reference to the Course struct variable that has the course information. Yet, the Course struct doesn’t hold any information about the student at all. Once the user enters all students and course information, the system must print out all information entered by the user for verification.

The following is a complete list of the system requirements:

1. Define a Student struct the holds the following information about each student:

1. First name, which is a string of length 19.

2. Last Name, which is a string of length 19.

3. Student ID, which is a 5-digit number.

4. A pointer to the course student registered in.

2. Define a Course struct that holds the following information about each course:

1. Course code, which is a 7-alphanumeric string.

2. Course name, which is a string of length 24.

3. Course struct must be a type defined unnamed struct.

4. The system should ask the user for the number of students they wish to save.

5. For each student, the system should prompt the user to enter their information (i.e. student information).

6. For the student’s course, the system should prompt the user to enter the course information.

7. Once all students and their courses are entered, the system must print all their information for the user verification.

Solutions

Expert Solution

//program

#include <stdio.h>
#include <stdlib.h>
// structure for Student
struct Student
{
   char firstName[19];
   char lastName[19];
   signed int id;
   struct Course *reg;
};
// structure for Course
typedef struct Course
{
   char code[7];
   char name[24];
}course;
int main()
{
   int n,i;
   printf("Enter the number of students they wish to save :");
   scanf("%d",&n);
   struct Student st[n];
   //Reading Student details
   for(i=0;i<n;i++)
   {
       printf("\nEnter Student %d details\n",i+1);
       printf("Enter the student First Name :");
       scanf("%s",st[i].firstName);
       printf("Enter the student Last Name :");
       scanf("%s",st[i].lastName);
       printf("Enter the student ID :");
       scanf("%ld",&st[i].id);
       st[i].reg = malloc(sizeof(struct Course));
       printf("Enter the student Course code :");
       scanf("%s",st[i].reg->code);
       printf("Enter the student Course Name :");
       scanf("%s",st[i].reg->name);
   }
   printf("\nThe Student Details are.....\n");
   printf("FirstName\tLastName\tID\tCoursecode\tCourseName\n\n");
   //Displaying Student details
   for(i=0;i<n;i++)
   {
       printf("%s\t\t%s\t\t%ld\t%s\t\t%s\n\n",st[i].firstName,st[i].lastName,st[i].id,st[i].reg->code,st[i].reg->name);
      
   }
return 0;
}

Screen shot of the program

Screen shot of the output

Please comment if any query


Related Solutions

In this Question using c++, you are to develop an employee management system using classes. You...
In this Question using c++, you are to develop an employee management system using classes. You need to develop two classes: Date and Employee. The Date class has the three attributes (int): month, day, and year. The class has the following member functions: • string getDate(void): returns a string with the date information (e.g, Mach 27, 2020). In addition to these, declare and implement proper constructors, a copy constructor, a destructor, and getters and setters for all data members. The...
You are using ONLY Programming Language C for this: In this program you will calculate the...
You are using ONLY Programming Language C for this: In this program you will calculate the average of x students’ grades (grades will be stored in an array). Here are some guidelines to follow to help you out: 1. In your program, be sure to ask the user for the number of students that are in the class. The number will help in declaring your array. 2. Use the function to scan the grades of the array. To say another...
bus reservation system code using c language in this system we can add seat and remove....
bus reservation system code using c language in this system we can add seat and remove. this code will be in c language using 2 d aray
how can benefit from C++ to develop a simple system for diagnosing number of people whom...
how can benefit from C++ to develop a simple system for diagnosing number of people whom affected by Coronavirus during a period of two weeks depending on the temperature and Oxygen rate of each individual person. Note: the temperature on the normal person is (37) and the Oxygen rate is above (90).
Develop an algorithm and implement Optimal Page Replacement algorithm using C++. Determine the number of page...
Develop an algorithm and implement Optimal Page Replacement algorithm using C++. Determine the number of page faults and page hits by considering the Frame size=4, ReferenceString:2 4 6 7 8 2 4 9 13 9 2 7 2 6 1 4 9 2
Describe to a parent how you develop reading abilities using the whole language approach. How can...
Describe to a parent how you develop reading abilities using the whole language approach. How can you collaborate with families to support this method at home?
Programming language: C++   suggested software: Code::Blocks Develop an algorithm and write a C++ program that computes...
Programming language: C++   suggested software: Code::Blocks Develop an algorithm and write a C++ program that computes the final score of a baseball game. Use a loop to read the number of runs scored by both teams during each of nine innings. Display the final score afterward. Submit your design, code, and execution result via file, if possible
Code in C-language programming description about convert binary number to decimal number.
Code in C-language programming description about convert binary number to decimal number.
Develop a program using Threads in C/C++ to estimate the value of PI using the Monte...
Develop a program using Threads in C/C++ to estimate the value of PI using the Monte Carlo method use: C/C++ #include srand((unsigned)(myid)); x = ((double)rand()) / ((double)RAND_MAX); y = ((double)rand()) / ((double)RAND_MAX); Your program will allow the user to specify the number of threads (range 1 to 10) and the total number of data points (range 10 to 1,000,000) used for the Monte Carlo simulation on the command line. Note, DO NOT assume the number of data points is always...
Develop a program using Threads in C/C++ to estimate the value of PI using the Monte...
Develop a program using Threads in C/C++ to estimate the value of PI using the Monte Carlo method use: C/C++ #include srand((unsigned)(myid)); x = ((double)rand()) / ((double)RAND_MAX); y = ((double)rand()) / ((double)RAND_MAX); Your program will allow the user to specify the number of threads (range 1 to 10) and the total number of data points (range 10 to 1,000,000) used for the Monte Carlo simulation on the command line. Note, DO NOT assume the number of data points is always...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT