0% found this document useful (0 votes)
42 views6 pages

Ex No 1 2 3

The document contains code for three C++ programs that demonstrate classes and objects: 1) A student class that gets and displays student data like roll number, name, and marks. Two student objects are created and their data is input and output. 2) An Armstrong number class that checks if a number is an Armstrong number based on the sum of its digits. 3) An employee class that gets and displays employee data like name, address, experience, and salary. Two employee objects are created and their data is input and output.

Uploaded by

Ebenezer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views6 pages

Ex No 1 2 3

The document contains code for three C++ programs that demonstrate classes and objects: 1) A student class that gets and displays student data like roll number, name, and marks. Two student objects are created and their data is input and output. 2) An Armstrong number class that checks if a number is an Armstrong number based on the sum of its digits. 3) An employee class that gets and displays employee data like name, address, experience, and salary. Two employee objects are created and their data is input and output.

Uploaded by

Ebenezer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

II CSE

PROGRAM
#include<iostream.h>
#include<conio.h>
class student
{
int rno,m1,m2;
char name[25];
public:
void getdata()
{
cout<<"Enter the Roll No";
cin>>rno;
cout<<"Enter the Name";
cin>>name;
cout<<"Enter the 2 Marks";
cin>>m1>>m2;
}
void putdata()
{
cout<<"\nRoll No:"<<rno;
cout<<"\nName :"<<name;
cout<<"\nMark1:"<<m1<<" Mark2:"<<m2<<"\n";
}};
void main()
{
clrscr();
student s1,s2;
s1.getdata();
s2.getdata();
cout<<"Student Detail";
s1.putdata();
s2.putdata();
getch();
}

OUTPUT:
Enter the Roll No23

CS6311-Programming and Data Structures II Laboratory

II CSE

Enter
Enter
Enter
Enter
Enter

the
the
the
the
the

NameArun
2 Marks78 89
Roll No45
NameKumar
2 Marks98 79

Student Detail
Roll No:23
Name :Arun
Mark1:78 Mark2:89
Roll No:45
Name :Kumar
Mark1:98 Mark2:79

PROGRAM
#include<iostream.h>
#include<conio.h>

CS6311-Programming and Data Structures II Laboratory

II CSE

class armstrong
{
int n,a,s,r;
public:
void getdata()
{
cout<<"\nEnter the Number";
cin>>n;
a=n;
s=0;
while(n!=0)
{
r=n%10;
s=s+r*r*r;
n=n/10;
}}
void putdata()
{
if(a==s)
cout<<"\nThe Given Number is an armstrong";
else
cout<<"\nThe Given Number is Not an armstrong";
}};
void main()
{
clrscr();
armstrong a;
a.getdata();
a.putdata();
getch();
}
OUTPUT:
Enter the Number153
The Given Number is an armstrong

CS6311-Programming and Data Structures II Laboratory

II CSE

PROGRAM
#include<iostream.h>
#include<conio.h>
class employee
{

CS6311-Programming and Data Structures II Laboratory

II CSE

char name[50];
char address[50];
float salary;
float year;
public:
void getdata()
{
cout<<"Enter the Name...";
cin>>name;
cout<<"Enter the Address...";
cin>>address;
cout<<"Enter the Year of Experience and Salary...";
cin>>year>>salary;
}
void putdata()
{
cout<<"\nName:"<<name<<"\nAddress:"<<address<<"\nYear of
Experience:"<<year<<"\nSalary:"<<salary;
}};
void main()
{
clrscr();
employee e1,e2;
e1.getdata();
e2.getdata();
cout<<"\nEMPLOYEE DETAIL\n";
e1.putdata();
e2.putdata();
getch();
OUTPUT:
Enter The Name...Arun
Enter the Address...Chennai-45
Enter the year of Experience and salary...5 20000
Enter The Name...Kumar
Enter the Address...Chennai-89

CS6311-Programming and Data Structures II Laboratory

II CSE

Enter the year of Experience and salary...10 50000


EMPLOYEE DETAIL
Name:Arun
Address:Chennai-45
Year of Experience:5
Salary:20000
Name:Kumar
Address:Chennai-89
Year of Experience:10
Salary:50000

CS6311-Programming and Data Structures II Laboratory

You might also like