Question

C++ program 1. Write a structure (struct) for a course information that contains: subject(string), course number(int),...

C++ program

1. Write a structure (struct) for a course information that contains: subject(string), course number(int), section number (int), and department name (string). Then in a application program, ask a user to input the necessary information and populate a structure.

Homework Answers

Answer #1
#include <iostream>
using namespace std;

struct course{
   string subject;
   int courseNumber;
   int sectionNumber;
   string departmentName;
};

int main(){
    struct course c;
    
   cout<<"Enter subject: ";
    cin>>c.subject;
    
    cout<<"Enter course number: ";
    cin>>c.courseNumber;
    
   cout<<"Enter section number: ";
    cin>>c.sectionNumber;
    
   cout<<"Enter department name: ";
    cin>>c.departmentName;
    
   cout<<"Subject: "<<c.subject<<endl;
    cout<<"Course number: "<<c.courseNumber<<endl;
   cout<<"Section number: "<<c.sectionNumber<<endl;
   cout<<"Department name: "<<c.departmentName<<endl;
   
   return 0;
}

Know the answer?
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
Similar Questions
Write C++ program to create a student record include a student ID, first name, nickname, course,...
Write C++ program to create a student record include a student ID, first name, nickname, course, subject, and subject marks. Task: Create a function to insert a number of students in the record. Create a function to print all student information by a table. Create a function to print all student information that they're in a specific course chosen by user input. Create a function to search for a student by student ID and print student information. Create a function...
Write a Java program with a method public String replaceChar(String p, int k, char c) {...
Write a Java program with a method public String replaceChar(String p, int k, char c) { } that given a String p, an int k, and a char c, returns a String with the kth character replaced by c. Of course, 0<=k<=p.length()-1, otherwise raise an exception or error.
Question 1: Write a C program that stores student information in structure and display it. Question...
Question 1: Write a C program that stores student information in structure and display it. Question 2: In addition to the first question, you are expected to create one more structure for courses. Then, structures must be filled by user inputs. After filling your structures, you will let user to get any student enroll to any course from the course list. Hint: To achieve these steps, you must use pointer in your student structure to link it to course structure.
Create a program which uses each struct declared in problem 1 and accesses each member of...
Create a program which uses each struct declared in problem 1 and accesses each member of each struct. (a) Create a variable using each struct and initialize it with some mock data of your choosing. (b) Print the members of each struct separated by a newline. (c) Modify each member of each struct to something different. (d) Print all members again. Save your code as prob2.c. This is Problem 1: struct ProductData {     int ID;     char Name[50];     float Price;     int...
C++ Question about Struct and Vector) Item Number format : box a11b2 struct itemNumber {   ...
C++ Question about Struct and Vector) Item Number format : box a11b2 struct itemNumber {    string name; // Item name char a, b; // Numbers int num1, num2; // Numbers } 1. How do I put struct in vector? 2. How do I sort them by comparing num in vector? ex) (in this way) a1b1 box1 a1b5 box2 a2b3 box3 a5b1 box4 ... 3. How do I change the name of item in the structure in the vector when...
C++ Part B: (String) Program Description: Write a word search program that searches an input data...
C++ Part B: (String) Program Description: Write a word search program that searches an input data file for a word specified by the user. The program should display the number of times the word appears in the input data file. In addition, the program should count and display the number of grammatical characters in the input data file. Your program must do this by providing the following functions : void processFile(ifstream &inFile, string wordSearch, int &wordCount, int &grammaticalCount) ; (15%)...
Write a program that prompts the user to enter a string and displays the number of...
Write a program that prompts the user to enter a string and displays the number of characters it contains, fourth character, and last character. Note: The string may contain blanks. For example: “C++ programming is fun”. You should write a complete program.
Write a Python program to ask user input of a string, then ask user input of...
Write a Python program to ask user input of a string, then ask user input of what letters they want to remove from the string. User can either put in "odd", "even" or a number "n" that is greater than 2. When user input "odd", it will remove the characters which have odd numbers in the sequence of the string. When user input "even", it will remove the characters which have even numbers in the sequence of the string. When...
For the following questions, use the definitions of the given structure. struct Date {       int yy,...
For the following questions, use the definitions of the given structure. struct Date {       int yy, mm, dd; }; struct Emp {       char EmpName[25];       float Salary;       struct Date hired; }; struct Dep {       struct Emp manager;       struct Emp worker[25];       float Profits; }; Define a struct Date variable called Date1 and initialize it to February 25, 1957, in the correct format. Define a struct Emp variable called Person1 and initialize it to “Roger”, with a salary of $50,000, who was hired...
c++ 1. Write a program that takes in a string as an input of any size...
c++ 1. Write a program that takes in a string as an input of any size and replaces all vowel letters in the string with an ‘x’. You must use Logical Operators and implement it using a user-defined function.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT