Professional Documents
Culture Documents
#include<iostream>
using namespace std;
struct phone{
int countrycode;
int citycode;
int number;
};
int main(){
phone p1;
phone p2;
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;
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;
if (option == 1){
}
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;
}