You are on page 1of 8

Lab report 04

Title: Function(reference,const,default)

Course title: Object Oriented Programming


Course code: CSE-160
1 Year 2nd Semester Examination 2021
st

Date of Submission: 27/10/2022

Submitted to-

Dr. MD. Ezharul Islam


Professor
Department of Computer Science and Engineering
Jahangirnagar University
Savar, Dhaka-1342

Sl Class Roll Exam Roll Name

01 381 Shahed Annam

Department of Computer Science and Engineering


Jahangirnagar University
Savar, Dhaka, Bangladesh
Problem Number: 1

#include<bits/stdc++.h>

using namespace std;

struct Time

int hour;

int minute;

int second;

};

struct employee

Time entry;

Time exit;

Time duration;

};

void display(employee x)

cout<<"Work duration ";

cout<<x.duration.hour<<":";

cout<<x.duration.minute<<":";

cout<<x.duration.second;

cout<<endl;

employee compute(employee x)

employee y;

int b,c,d,e;
b=9*3600;

c=x.exit.hour*3600+x.exit.minute*60+x.exit.second;

e=c-b;

if(e<0)

e= (e)+24*60*60;

b= e/3600;

c= (e-(b*3600))/60;

d= (e-(b*3600)-c*60);

y.duration.hour = b;

y.duration.minute=c;

y.duration.second=d;

return y;

employee compute(int exh,int exm,int exs, int eh=9,int em=0,int es=0)

employee y;

int b,c,d,e;

b=eh*3600+em*60+es;

c=exh*3600+exm*60+exs;

e=c-b;

if(e<0)

e= (e)+24*60*60;

}
b= e/3600;

c= (e-(b*3600))/60;

d= (e-(b*3600)-c*60);

y.duration.hour = b;

y.duration.minute=c;

y.duration.second=d;

return y;

employee input(employee &x)

cout<<"Exit moment time"<<endl;

cin>>x.exit.hour;

cin>>x.exit.minute;

cin>>x.exit.second;

int main()

employee x,dif,differ;

input(x);

dif = compute(x);

differ = compute(x.exit.hour,x.exit.minute,x.exit.second);

display(dif);

display(differ);

return 0;

}
Problem Number: 2

#include<bits/stdc++.h>

using namespace std;

struct System

int feet;

float inches;

};

struct Room

System length;

System width;

};

void display(const float x)

cout<<"Area is "<<x<<endl;

float compute(Room x)

float a,b;

a = x.length.feet + (x.length.inches/12);

b = x.width.feet + (x.width.inches/12);

return (a*b);

}
float compute(float lf,float wf,float li=0,float wi=0)

float a,b;

a = lf + (li/12);

b = wf + (wi/12);

return (a*b);

Room input(Room &r)

Room x;

cout<<"Enter length"<<endl;

cout<<"In Feet ";

cin>>r.length.feet;

cout<<"In inches ";

cin>>r.length.inches;

cout<<"Enter width"<<endl;

cout<<"In Feet ";

cin>>r.width.feet;

cout<<"In inches ";

cin>>r.width.inches;

int main()
{

int i;

Room r;

float area,area2;

input(r);

area = compute(r);

area2 = compute(r.length.feet,r.width.feet); //by default setting inchess 0

display(area);

cout<<"Setting inches by default zero"<<endl;

display(area2); //by default setting inchess 0

return 0;

You might also like