Advertisement
arfin97

Structure and Call by reference.

Sep 6th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct BankAccount{
  5.     string holder_name;
  6.     int account_number;
  7.     float balance;
  8. };
  9.  
  10. typedef struct BankAccount BankAccount;
  11.  
  12. string richer(BankAccount s1, BankAccount s2){
  13.     if(s1.balance > s2.balance) return s1.holder_name;
  14.     else s2.holder_name;
  15. }
  16.  
  17. int bigBigNumber(int *val, int *sq, int *cube){
  18.     *sq = (*val)*(*val);
  19.     *cube = (*val)*(*val)*(*val);
  20. }
  21.  
  22. int main(){
  23.     BankAccount rakkhosh, khokkosh;
  24.  
  25.     rakkhosh.holder_name = "Rakkhosh";
  26.     rakkhosh.account_number = 4410;
  27.     rakkhosh.balance = 30023.3;
  28.  
  29.     khokkosh.holder_name = "Khokkosh";
  30.     khokkosh.account_number = 234423;
  31.     khokkosh.balance = 33.44;
  32.  
  33.     cout << richer(rakkhosh, khokkosh) << endl;
  34.  
  35.     int val = 4;
  36.     int sq, cube;
  37.     bigBigNumber(&val, &sq, &cube);
  38.     cout << val << endl;
  39.     cout << sq << endl;
  40.     cout << cube << endl;
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement