You are on page 1of 4

TASK 1

#include<iostream>
using namespace std;
struct phone{
int countrycode;
int citycode;
int number;

};

int main(){
phone p1;
phone p2;

p1.countrycode = p2.countrycode= 92;


p2.countrycode;

cout << "Enter citycode";


cin >> p1.citycode;

cout << "Enter number";


cin >> p1.number;

cout << "Phone number is: 0";


cout << p1.citycode << p1.number;

cout << "Enter citycode";


cin >> p2.citycode;

cout << "Enter number";


cin >> p2.number;

cout << "Phone number is: 0";


cout << p2.citycode << p2.number;
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 << "3.To display details of all the stored accounts." << endl;
cout << "4.To 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;
}

You might also like