Answer to Question #329840 in C++ for Acy

Question #329840

A C++ program to print the members of a structure using dot operators


1
Expert's answer
2022-04-17T13:53:47-0400
#include <iostream>
#include <string>
using namespace std;


struct Student {
    string name;
    unsigned long id;
    int marks;
};


int main() {
    Student alice = {"Alice", 1234567, 98};
    Student bob   = {"Bob",   9876543, 65};


    cout << "Name:  " << alice.name << endl;
    cout << "ID:    " << alice.id << endl;
    cout << "Marks: " << alice.marks << endl << endl;


    cout << "Name:  " << bob.name << endl;
    cout << "ID:    " << bob.id << endl;
    cout << "Marks: " << bob.marks << endl;


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS