nested struct
//struct di dlm struct
#include<iostream.h>
#include<conio.h>
void main()
{
struct data
{
char nim[10];
char nama[35];
};
data x;
struct data2
{
int nilai1, nilai2, total;
struct data x;
};
data2 y;
cout<<"input NIM : ";
cin>>y.x.nim;
cout<<"input nama : ";
cin>>y.x.nama;
cout<<"input nilai 1 : ";
cin>>y.nilai1;
cout<<"input nilai 2 : ";
cin>>y.nilai2;
cout<<"NIM : "<<y.x.nim<<endl;
cout<<"nama : "<<y.x.nama;
cout<<"total nilai : "<<y.nilai1 + y.nilai2;
getch();
}
Comments
Post a Comment