Question

In: Computer Science

Create a C structure which stores information about a student. Each student should be represented by...

Create a C structure which stores information about a student. Each student should be represented by a student ID (integer), first name, last name, day, month and year of birth, and program code (string). Write a C program which creates an array of 100 of these structures, then prompts the user to enter data from the keyboard to fill the array. If an ID of 0 is entered, data entry should finish, and the list of students should be printed to the screen.

Solutions

Expert Solution

CODE -

#include<stdio.h>

// Create a struct for student

struct student

{

    int student_id;

    char first_name[20];

    char last_name[20];

    int day_birth;

    int month_birth;

    int year_birth;

    char program_code[20];

};

// Main Function

int main()

{

    // Create an array of 100 structs of student

    struct student students[100];

    int i=0;

    // Read input from the user for different students till user wants to quit by entering 0 as student id

    while(i<100)

    {

        printf("\nEnter the ID of student %d: ", i+1);

        scanf("%d", &students[i].student_id);

        // Break out of loop if 0 is entered as student id

        if(students[i].student_id == 0)

            break;

        printf("Enter the first name of student %d: ", i+1);

        scanf("%s", &students[i].first_name);

        printf("Enter the last name of student %d: ", i+1);

        scanf("%s", &students[i].last_name);

        printf("Enter the day of birth of student %d: ", i+1);

        scanf("%d", &students[i].day_birth);

        printf("Enter the month of birth of student %d: ", i+1);

        scanf("%d", &students[i].month_birth);

        printf("Enter the year of birth of student %d: ", i+1);

        scanf("%d", &students[i].year_birth);

        printf("Enter the program code of student %d: ", i+1);

        scanf("%s", &students[i].program_code);

        i++;

    }

    // Display student details

    printf("\nStudent Details:\n\n");

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

    {

        printf("\nStudent %d\n\n", j+1);

        printf("ID: %d\n", students[j].student_id);

        printf("First Name: %s\n", students[j].first_name);

        printf("Last Name: %s\n", students[j].last_name);

        printf("Date of Birth(dd-mm-yyyy): %d-%d-%d\n", students[j].day_birth, students[j].month_birth, students[j].year_birth);

        printf("Program Code: %s\n", students[j].program_code);

    }

    return 0;

}

SCREENSHOTS -

CODE -

OUTPUT -

If you have any doubt regarding the solution, then do comment.
Do upvote.


Related Solutions

Create a C structure which stores information about a book. Each book should have the following...
Create a C structure which stores information about a book. Each book should have the following data: Author (string), Title (string), Publisher (string), Year (int), ISBN (int), Genre (string), Price (float). Write a C program which creates an array of 100 of these structures, then prompts the user to enter book information to fill the array. The data entry should stop when the array is full, or when the user enters 0 for the ISBN.
Create a class called Student which stores • the name of the student • the grade...
Create a class called Student which stores • the name of the student • the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into the grade field. • Calculate the...
Write C code to create a structure called time_of_day, which stores the current time in hours,...
Write C code to create a structure called time_of_day, which stores the current time in hours, minutes, and seconds. All the fields should be integers except for seconds, which should be a floating point value. Write a C function called check_time, which takes a pointer to a time_of_day structure as input, and return 1 if the time is valid (0 to 23 hours, 0 to 59 minutes, 0 to 59.999999 seconds) and 0 otherwise. Assume that times are stored in...
Create a python application that inputs, processes and stores student data. Specifications: 1. Your application should...
Create a python application that inputs, processes and stores student data. Specifications: 1. Your application should be able to accept Student data from the user and add the information in a file type of your choice. 2. your application is a menu driven and allow the user to choose from the following menu Menu: 1 – Add students to file 2 – print all the student information 3 – print specific student information using studentID 4 – Exit the program...
Student Structure Assignment Create a Student Structure globally consisting of student ID, name, completed credits, and...
Student Structure Assignment Create a Student Structure globally consisting of student ID, name, completed credits, and GPA. Define one student in main() and initialize the student with data. Display all of the student’s data on one line separated by tabs. Create another student in main(). Assign values to your second student (do not get input from the user). Display the second student’s data on one line separated by tabs. Create a third student in main(). Use a series of prompts...
Java (a) Create a class Router which stores the information of a router. It includes the...
Java (a) Create a class Router which stores the information of a router. It includes the brand, the model number (String) and the price (double, in dollars). Write a constructor of the class to so that the information mentioned is initialized when a Router object is created. Also write the getter methods for those variables. Finally add a method toString() to return the router information in the following string form. "brand: Linksys, model number: RVS4000, price: 1080.0" Copy the content...
(a) Create a class Webcam which stores the information of a webcam. It includes the brand,...
(a) Create a class Webcam which stores the information of a webcam. It includes the brand, the model number (String) and the price (double, in dollars). Write a constructor of the class to so that the information mentioned is initialized when a Webcam object is created. Also write the getter methods for those variables. Finally add a method toString() to return the webcam information in the following string form. "brand: Logitech, model number: B525, price: 450.0" Copy the content of...
Create a structure In C program named Student with the following components and appropriate data types:...
Create a structure In C program named Student with the following components and appropriate data types: Name, ID, CGPA i. Create an Array of Students of size three and take user input to fill the array. ii. Now find the student with the least CGPA and display his or hers Name, ID and CGPA.
C++ Question Design and implement a class that stores a list of students. Each student has...
C++ Question Design and implement a class that stores a list of students. Each student has the list of courses he/she registered for the semester. You will need a container of containers to hold this list of students. Choose the optimal container for this exercise, noting that no duplicates should be permitted. Use STL classes with iterators to navigate the list. Develop a test program, which allows options to add, remove, and list students and their associated course lists. Also...
Each student should choose a company and create a new product or service for the company...
Each student should choose a company and create a new product or service for the company chosen (It can be any company). The new product or service must be consistent with the company’s current offerings. An example of an inconsistent product offering would be if Chrysler (an automotive company) began to sell chocolate. The final project should consist of the following items: 1. Executive Summary This section should focus on providing a concise overview of your new product or service...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT