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.
#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; }
Get Answers For Free
Most questions answered within 1 hours.