EX - 9
EX - 9
#include <cstring>
class Employee {
public:
char name[100];
float salary;
strcpy(name, empName);
salary = empSalary;
void display() {
};
int main() {
emp.display();
return 0;
}
Employee Name: Scott
#include <string>
class Employee {
private:
string name;
float salary;
string department;
public:
void getData() {
getline(cin, name);
cin.ignore();
getline(cin, department);
};
int main() {
Employee emp;
emp.getData();
emp.showData();
return 0;
Employee Details:
Name: RAHUL
Salary: 200000
Department: CSDS
#include <iostream>
#include <string>
class Student {
private:
public:
void getData() {
cout << "Marks: " << marks[0] << ", " << marks[1] << ", " << marks[2] << endl;
} else {
};
int main() {
Student students[10];
for (int i = 0; i < 10; i++) {
cout << "Enter details for Student " << (i + 1) << ":";
students[i].getData();
students[i].showData();
return 0;
Student 1:
Student 2:
Student 1:
Name: Alice
Roll Number: 1
Marks: 45 55 60
Status: PASS
Student 2:
Name: Bob
Roll Number: 2
Marks: 35 25 40
Status: FAIL
#include <iostream>
return a+b;
return a+b+c;
return a+b;
int main()
int x=5,y=10,z=15;
return 0;
}
sum of two integers :15
class Shapes{
private:
float area;
public:
area=length*width;
area=side*side;
};
int main()
Shapes shape;
shape.calArea(5,2.5);
shape.calArea(7);
return 0;
}
Area of rectangle :12.5