Task 1
#include <iostream>
using namespace std;
struct timey {
int hour;
int minute;
int second;
};
timey addTimes(timey time1, timey time2)
timey result;
result.second = time1.second + time2.second;
if (result.second >= 60)
result.second -= 60;
time1.minute += 1;
result.minute = time1.minute + time2.minute;
if (result.minute >= 60) {
result.minute -= 60;
time1.hour += 1;
}
result.hour = time1.hour + time2.hour;
return result;
int main() {
timey time1, time2, result;
cout << "Enter first time (hour minute second): ";
cin >> time1.hour >> time1.minute >> time1.second;
cout << "Enter second time (hour minute second): ";
cin >> time2.hour >> time2.minute >> time2.second;
result = addTimes(time1, time2);
cout << "The new time is: " << result.hour << " hours "
<< result.minute << " minutes " << result.second << " seconds" << endl;
return 0;
}
Task 2
#include <iostream>
using namespace std;
struct empl
string name;
string designation;
string office_phone;
string mobile_no;
}emp[5];
int main()
for(int i=0; i<5;i++)
cout<<"Enter name of employee "<<endl;
getline(cin,emp[i].name);
cout<<"Enter designation L1 ,L2 ,L3 "<<endl;
getline(cin,emp[i].designation);
cout<<"Enter office phone number "<<endl;
getline(cin,emp[i].office_phone);
cout<<"Enter mobile number "<<endl;
getline(cin,emp[i].mobile_no);
for(int i=0;i<5;i++)
{
cout<<"****************employee no"<< i+1<<"************"<<endl;
cout<<"name "<<emp[i].name<<endl;
cout<<"Designation "<<emp[i].designation<<endl;
cout<<"office number "<<emp[i].office_phone<<endl;
cout<<"Mobile number "<<emp[i].mobile_no<<endl;
return 0;
Task 3
#include<iostream>
using namespace std;
struct complex_number
int real_part;
int img_part;
};
int main()
complex_number n1,n2;
int sum_real,sum_img;
cout<<"enter real part for first number "<<endl;
cin>>n1.real_part;
cout<<"enter real part for second number "<<endl;
cin>>n2.real_part;
cout<<"enter imaginary part for first number "<<endl;
cin>>n1.img_part;
cout<<"enter imaginary part for second number "<<endl;
cin>>n2.img_part;
sum_real = n1.real_part+n2.real_part;
sum_img=n1.img_part+n2.img_part;
cout<<"Sum is ="<<sum_real<<"+"<<sum_img<<"i"<<endl;
Task 4
#include <iostream>
using namespace std;
struct employee_full_name
string first_name;
string last_name;
};
struct employee_adress
string house_no;
string street_no;
string Area;
string city;
};
struct empl
employee_full_name name;
employee_adress adress;
string office_phone;
string mobile_no;
}emp[5];
int main()
for(int i=0; i<5;i++)
cout<<"Enter first name of employee "<<endl;
getline(cin,emp[i].name.first_name);
cout<<"Enter last name of employee "<<endl;
getline(cin,emp[i].name.last_name);
cout<<"Enter house number "<<endl;
getline(cin,emp[i].adress.house_no);
cout<<"Enter street number "<<endl;
getline(cin,emp[i].adress.street_no);
cout<<"Enter Area "<<endl;
getline(cin,emp[i].adress.Area);
cout<<"Enter city name "<<endl;
getline(cin,emp[i].adress.city);
cout<<"Enter office phone number "<<endl;
getline(cin,emp[i].office_phone);
cout<<"Enter mobile number "<<endl;
getline(cin,emp[i].mobile_no);
}
for(int i=0;i<5;i++)
cout<<"****************employee no"<< i+1<<"************"<<endl;
cout<<"first name"<<emp[i].name.first_name<<endl;
cout<<"Last name"<<emp[i].name.last_name<<endl;
cout<<"House no. "<<emp[i].adress.house_no<<endl;
cout<<"Street no. "<<emp[i].adress.street_no<<endl;
cout<<"Area "<<emp[i].adress.Area<<endl;
cout<<"City "<<emp[i].adress.city;
cout<<"office number "<<emp[i].office_phone<<endl;
cout<<"Mobile number "<<emp[i].mobile_no<<endl;
return 0;
Task 5
#include <iostream>
using namespace std;
int factorial (int n)
int fact=1;
for(int i=1;i<=n;i++)
fact *=i;
return (fact);
}
int main()
int n;
cout<<"Enter a number whose factorial is required "<<endl;
cin>>n;
cout<<"factorial of the number is "<<factorial(n)<<endl;
return 0;
Task 6
#include<iostream>
using namespace std;
int fibo(int x)
if(x<=1)
return (x);
else
return (fibo(x-1)+fibo(x-2));
int main()
int a,sum=0;
cout<<"Enter how many terms should be added "<<endl;
cin>>a;
for(int i=0;i<=a;i++)
sum +=fibo(a);
cout<<"The sum of the number of terms you gave is "<<sum<<endl;
return 0;