#include
struct course
{
int couno;
int coufees;
};
struct student
{
int studno;
course sc;
course sc1;
};
void main( )
{
student s1;
s1.studno=100;
s1.sc.couno=123;
s1.sc.coufees=5000;
s1.sc1.couno=200;
s1.sc1.coufees=5000;
int x = s1.sc.coufees + s1.sc1.coufees;
cout<< “\n Student Number: ”< cout<<”\n Total Fees: Rs.”<< x;
}
Output :
Student Number: 100
Total Fees: Rs.10000
s1 adalah nama struct variable. sc adalah nama struct student luar. couno adalah anggota struct course. Seperti ituah anggota nested struct diakses.
.jpg)
1 komentar:
Posting Komentar