...
/Solution Review: Account Number of Customers with Balance < $500
Solution Review: Account Number of Customers with Balance < $500
Let's go over the solution review of the challenge given in the previous lesson.
We'll cover the following...
Solution #
Press the RUN button and see the output!
Press + to interact
#include <iostream>using namespace std;// Structure Accountstruct Account {// Stores the namestring name;// Stores the account numberint number;// Stores the total amountdouble balance;};// Function check_accountvoid check_account(struct Account p[], int arr[], int size) {// Traverse arrayfor (int i = 0; i < size; i++) {// Check if balance less than 500if (p[i].balance < 500) {// Store account numberarr[i] = p[i].number;} else {// Store -1arr[i] = -1;}}}// print_arr functionvoid print_arr(int arr[], int size) {for (int i = 0; i < size; i++) {cout << arr[i] << endl;}}// print_Account functionvoid print_Account(struct Account p[], int size) {for (int i = 0; i < size; i++) {cout << "Person" << i + 1 << " details:" << endl;cout << p[i].name << endl;cout << p[i].number << endl;cout << p[i].balance << endl;cout << endl;}}// main functionint main() {// Declare array of type intint arr[3];// Declare structure arraystruct Account p[3];// Intialize structure arrayp[0] = {"John",578328,890};p[1] = {"Alex",908210,430.2 };p[2] = {"Kim",165216,98.5};// Call print_Account functionprint_Account(p, 3);// Call check_account functioncheck_account(p, arr, 3);// Call print_arr functionprint_arr(arr, 3);return 0;}