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 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...
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.
***IN C++*** Create student structure with the following fields:  Name (cstring or null-terminated character array)...
***IN C++*** Create student structure with the following fields:  Name (cstring or null-terminated character array)  Student ID (int – unique random value between 1000 and 9999)  grade (char – Values A thru F)  birthday (myDate – random value: range 1/1/2000 to 12/31/2005)  Home Town (string) Create an array of pointers to students of size 10. Example: Student *stuPtr[10]; Write a function that populates the array with 10 students. Example: populate(stuPtr); Write a display function that...
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...
Create a Java program that receives name, GPA, and graduation year information about a student as...
Create a Java program that receives name, GPA, and graduation year information about a student as user input and prints it to the console. Please use the following constructs in your program: Write your code in a Java class. Define name, GPA and graduation year as variables in our class. Create separate setter and getter methods for those variables. Use your main method, to receive the user input. Initialize an object of the class to call the setter methods and...
C++ Write a program to create a linked list which stores the details of employees(Employee number,...
C++ Write a program to create a linked list which stores the details of employees(Employee number, employee name, rate, hours worked). Create a menu to manage the emoployee data. MENU 1. ADD EMPLOYEE DETAILS 2. DELETE EMPLOYEE 3. SEARCH EMPLOYEE 4. PRINT EMPLOYEE PAYROLL 5. EXIT When the user selected option #4 the program should print the following pay report for each employee: EmpNo.     Name      Rate    Hours    Regular Pay      Overtime Pay     Gross Pay Any hours worked above 40 hours are...
(MUST BE DONE IN C (NOT C++)) In this task, you will create a structure with...
(MUST BE DONE IN C (NOT C++)) In this task, you will create a structure with arrays. You will have to create your own structure. However, make sure to meet these guidelines: - Give the structure whichever name you want. - It must have at least 3 members. - Two of the members must be arrays. - Your members should be of at least two different data-types. In other words, your members cannot be integers only (or floats, or doubles…)....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT