-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_and_object.cpp
More file actions
33 lines (28 loc) · 803 Bytes
/
class_and_object.cpp
File metadata and controls
33 lines (28 loc) · 803 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
#include <bits/stdc++.h>
using namespace std;
class Student
{
public:
char name[100];
int roll;
double cgpa;
};
int main()
{
Student a, b;
// a.cgpa = 3.50;
// a.roll = 61;
// char tmp[100] = "Fahad";
// strcpy(a.name, tmp);
// cout << a.name << " has got cgpa " << fixed << setprecision(2) << a.cgpa << " and his roll number is " << a.roll << endl;
// cin >> a.name >> a.cgpa >> a.roll;
// cin >> b.name >> b.cgpa >> b.roll;
cin.getline(a.name, 100);
cin >> a.cgpa >> a.roll;
getchar();
cin.getline(b.name, 100);
cin >> b.cgpa >> b.roll;
cout << a.name << " " << fixed << setprecision(2) << a.cgpa << " " << a.roll << endl;
cout << b.name << " " << fixed << setprecision(2) << b.cgpa << " " << b.roll << endl;
return 0;
}