-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStructureinCPP.cpp
More file actions
31 lines (25 loc) · 882 Bytes
/
StructureinCPP.cpp
File metadata and controls
31 lines (25 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//Program to use structure in C++
#include <iostream>
using namespace std;
struct Student{//the concept of structure is same as in C-Programming.
char name[20];//array of characters is used here
char address[20];
struct DOB{//nesting of structure also you can use without nesting in next structure
int day;
int month;
int year;
}birth;
};
int main()
{
Student std;//giving variable name to the structure
cout<<"Enter your name ";
cin>>std.name;
cout<<endl<<"Enter your address ";
cin>>std.address;
cout<<endl<<"Enter Date of birth in day, month and year";
cin>>std.birth.day>>std.birth.month>>std.birth.year;
cout<<"Name :"<<std.name<<endl;
cout<<"Address :"<<std.address<<endl<<"DOB:"<<std.birth.day<<"/"<<std.birth.month<<"/"<<std.birth.year;
return 0;
}