Question

Write a C++ program using structures which create
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

Sample Output:

Code to be copied by the user:

#include<iostream>

#include<string>

#define SIZE 50

using namespace std;

struct student

{

string name;

int age;

string major;

char grade;

};

int main()

{

int n;

struct student s[SIZE];

cout << "Enter the number of students: " << endl;

cin >> n;

for(int i=1;i<=n;i++)

{

cout << "Enter the details of student " << i << ":" << endl;

cout << "Name: " ;

cin >> s[i].name;

cout << "Age: " ;

cin >> s[i].age;

cout << "Major: " ;

cin >> s[i].major;

cout << "Grade: " ;

cin >> s[i].grade;

}

cout << "The details of the students are : " << endl;

cout << "Name \tAge \tMajor \tGrade" << endl;

cout << "-----------------------------------" << endl;

for(int i=1;i<=n;i++)

{

cout << s[i].name <<"\t" << s[i].age << "\t" << s[i].major << "\t" << s[i].grade << endl;

}

system("pause");

return 0;

}

Add a comment
Know the answer?
Add Answer to:
Write a C++ program using structures which create a structure called 'student' (structure should have name,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ASSIGNMENT: Student Data Write a program that uses two structures Name and Student to store the following information for multiple students 1. Create a NAME structure that consists of o First Name, M...

    ASSIGNMENT: Student Data Write a program that uses two structures Name and Student to store the following information for multiple students 1. Create a NAME structure that consists of o First Name, Middle Initial, and oLast Name. 2. Create a STUDENT structure that contains student information (Include the NAME structure within the Student information structure): o Name o email o Program (an enum type containing programs such as CSCI, DBMS, INFM, SDEV) ASSIGNMENT: Student Data Write a program that uses...

  • Visual C# Homework 2 You are to write a program which will create a class called...

    Visual C# Homework 2 You are to write a program which will create a class called Student Each student has a name age height and weight. These variables should be declared as private. Create the correct constructors and functions. In the main, you will create 5 students. Input the data for the 5 students from a file which already has information in it. Name the file “Information.txt”. After setting up all the data, it is time to sort based on...

  • Write a program (C++) that shows Game sales. The program should use a structure to store...

    Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...

  • Create a console application project and solution called “ConsoleWorkWithData.” using C# Create the following variables with...

    Create a console application project and solution called “ConsoleWorkWithData.” using C# Create the following variables with data type: a. FirstName: string data type b. LastName: string data type c. Student ID: int data type d. BirthDate: data time data type e. Grade: decimal data type Write all values in these variables to the screen in this format: a. --------------------------------------------------------- b. My name is Rieser Angie c. I’m a new student, and this is my first program d. ************************************** e. My...

  • Use PYTHON3 to create a program that asks the user for their name, and then prints...

    Use PYTHON3 to create a program that asks the user for their name, and then prints their initials. You must create a function called getInitials() that takes the name string and prints out the initials. It must be case insensitive and the initials must be printed in upper case. The program must contain a main() and a function called getInitials(), implemented as described in the function header comment given below. (You should include this function header comment in your own...

  • SC 111 - BMCC Exam Student Name: Type # 4 - 20 Points write a program...

    SC 111 - BMCC Exam Student Name: Type # 4 - 20 Points write a program that uses a structure named Student to store the following information about a Student: Name ID GPA Address The program should create three Student instances, store values, and pass all of them to a function that displays the information about the Student in a clearly formatted manner. The program also uses another function to calculate and display the average GPA of all three Students.

  • *** C++ *** Create a class called Student that contains a first name ( string) and...

    *** C++ *** Create a class called Student that contains a first name ( string) and an student id number (type long).     1. Include a member function called get_data( ) to get data from the user for insertion into the object,     2. Also include a function called display_data( ) that displays the student data. Then write a complete program that uses the class to do some computation. Your main function, main( ), should create a Dynamic Array of...

  • In C++ Write a program that contains a class called VideoGame. The class should contain the...

    In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....

  • Structures in C++ :- 1. Write a program that declares a structure to store the code...

    Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...

  • Program in C Student Data using Structs In this assignment you will create a program (using...

    Program in C Student Data using Structs In this assignment you will create a program (using multiple .c files) to solve the following problem: You have been hired by the university to create a program that will read in input from a .txt file. This input will contain a student name, student id #, their age and their current gpa. You should use the following struct for your student data: struct Student{                 char name[50];                 int id;                 float...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT