A C++ program to print the members of a structure using dot operators
#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;
}
Comments
Leave a comment