0% found this document useful (0 votes)
7 views2 pages

Subbmission

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)
7 views2 pages

Subbmission

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/ 2

1.

#include <iostream>
using namespace std;

class Point
{
private :
int x_coord;
int y_coord;
public :
void set_value(int x,int y);
void display();
void Add(int c);
};

void Point :: set_value(int x,int y)


{
x_coord = x;
y_coord = y;
}

void Point :: display()


{
cout<<"(x,y) = ("<<x_coord<<","<<y_coord<<")\n";
}

void Point :: Add(int c)


{
x_coord += c;
y_coord += c;
}

int main()
{
Point p,p1;
p1.set_value(20,20);
p.set_value(10,10);
p1.display();
p.display();
p.Add(3);
p.display();
return 0;
}
2.
#include <iostream>
using namespace std;

class Time
{
private :
int hrs;
int mins;
int secs;
public :
void input();
void display();
};

void Time :: input()


{
cin>>hrs;
cin>>mins;
cin>>secs;
}

void Time :: display()


{
cout<<"Time = "<<hrs<<":"<<mins<<":"<<secs<<"\n";
}

int main()
{
Time t;
t.input();
t.display();
return 0;
}

You might also like