-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstruct2.cpp
More file actions
34 lines (33 loc) · 733 Bytes
/
Copy pathstruct2.cpp
File metadata and controls
34 lines (33 loc) · 733 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
32
33
34
//program to define structure and creating function indside
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
struct emp //structure in cpp with access spacifiers like public ,private
{
//creating structure variable private
private:
int id;
float sallary;
char name[20];
//creating structure functions public
public:
void input()
{
cout<<"Enter id,name,sallary ";
cin>>id>>name>>sallary;
}
void show()
{
cout<<"id = "<<id<<endl<<"name = "<<name<<endl<<"sallary = "<<sallary<<endl;
}
};
int main(int argc, char const *argv[])
{
system("cls");
emp e1;
e1.input();
e1.show();
system("pause");
return 0;
}