TASK 1
#include<iostream>
using namespace std;
struct phone{
int countrycode;
int citycode;
int number;
};
int main(){
phone p1;
phone p2;
[Link] = [Link]= 92;
[Link];
cout << "Enter citycode";
cin >> [Link];
cout << "Enter number";
cin >> [Link];
cout << "Phone number is: 0";
cout << [Link] << [Link];
cout << "Enter citycode";
cin >> [Link];
cout << "Enter number";
cin >> [Link];
cout << "Phone number is: 0";
cout << [Link] << [Link];
return 0;
}
TASK 2
#include<iostream>
using namespace std;
struct point{
int x;
int y;
int z;
};
int main(){
point p1;
point p2;
int p3x, p3y, p3z;
cout << "Enter x coordinate of 1st point:";
cin >> p1.x;
cout << "Enter y coordinate of 1st point:";
cin >> p1.y;
cout << "Enter z coordinate of 1st point:";
cin >> p1.z;
cout << "Enter x coordinate of 2nd point:";
cin >> p2.x;
cout << "Enter y coordinate of 2nd point:";
cin >> p2.y;
cout << "Enter z coordinate of 2nd point:";
cin >> p2.z;
p3x = p1.x + p2.x;
p3y = p1.y + p2.y;
p3z = p1.z + p2.z;
cout << "Coordinates of third point are:";
cout<< p3x, p3y, p3z;
return 0;
}
TASK 3
#include<iostream>
#include <string>
using namespace std;
struct BankAccount {
char accountTitle[5];
int accountNumber;
int accountBalance;};
int data(int){
char accountTitle[5];
BankAccount accounts[3];
for (int i = 0; i < 3; i++){
int accountNumber;
int accountBalance;
if (accountNumber == 0 && i == 0)
{
accountTitle[5] = 'A';
accountBalance = 23456;
cout << "accountNumber is" << accountNumber << endl;
cout << "accountTitle is " << accountTitle[5] << endl << "balance
is:" << accountBalance << endl;
}
if (accountNumber == 2 && i == 1)
{
accountTitle[5] = 'B';
accountBalance = 23486;
cout << "accountTitle is " << accountTitle[5] << endl << "balance
is:" << accountBalance << endl;
}
if (accountNumber = 2 && i == 2)
{
accountTitle[5] = 'C';
accountBalance = 2349986;
cout << "accountTitle is " << accountTitle[5] << endl << "balance
is:" << accountBalance << endl;
}
}
return 0;
}
int main(){
BankAccount accounts[3];
int accountNumber, accountBalance;
char accountTitle[50];
int totalBal;
float averageBal;
char choice;
do{
int option;
cout << "Enter a number from 1-6" << endl;
cout << "1. To enter details for a new bank account." << endl;
cout << "2. For deleting an existing account" << endl;
cout << "[Link] display details of all the stored accounts." << endl;
cout << "[Link] display the total balance and average balance of all the
accounts." << endl;
cout << "5. Displays details of a specific account." << endl;
cin >> option;
if (option == 1){
cout << "Enter account title:" << endl;
gets_s(accountTitle, 50);
cout << "Enter account number:";
cin >>accountNumber;
cout << "Enter account balance:";
cin >> accountBalance;
}
else if (option == 2){
for (int j = 0; j < 50; j++){ accountTitle[j] = NULL; };
accountNumber = 0;
accountBalance = 0;
cout << "Your account has been deleted." << accountTitle <<
accountNumber << accountBalance;
}
else if (option == 3){
cout << "Details of all the stored accounts are : ";
for (int i = 0; i < 5; i++)
{
cout << "Account Number is :" << accounts[i].accountNumber;
cout << "Account Title is:" << accounts[i].accountTitle;
cout << "Account Balance is:" << accounts[i].accountBalance;
}
}
else if (option == 4){
int total = 0;
cout << "Total balance is:";
for (int i = 0; i < 3; i++){
total += accounts[i].accountBalance;
} cout << " " << total << endl;
cout << "Average balance is:" << total / 5;
}
else if (option == 5){
int i;
cout << "Enter account number:" <<endl;
cin >> i;
cout << "Details of specific account are:- "<<endl<<data(i);
cout << "Do you want to continue? Press Y";
cin >> choice;} while (choice == 'Y' || choice == 'y');
return 0;
}